Interview Prep/Linux/Permissions, Users & sudo

How do you lock or expire a user account?

IntermediateConceptPermissions, Users & sudo
Answer
sudo usermod -L alice          # lock password (prefixes hash with !)
sudo usermod -e 1 alice        # expire account (blocks all logins incl. SSH keys)
sudo chage -l alice            # view ageing info
sudo usermod -s /usr/sbin/nologin alice

-L alone does not stop SSH key logins; expiring the account or changing the shell does.

All Linux questions Roadmap: Linux

More on Permissions, Users & sudo