Linux user account management
Here is some useful command for managing user accounts in Linux environment
Replace testuser with your username :
sudo useradd testuser
Set a password for new user :
sudo passwd testuser
Add the new user to a group e.g sudo group :
sudo usermod -a -G sudo testuser
Seeing group membership for your user :
sudo groups testuser
Seeing a group members e.g sudo group :
cat /etc/group | grep sudo
Remove your user from a group e.g sudo group:
sudo deluser testuser sudo
Disallow user from logging in :
sudo usermod --expiredate 1 testuser
Opposite of above for re-enabling a user and set the expiration date to never :
sudo usermod --expiredate "" testuser
For lock a user account , This prepends a ! to the password hash so that no password will match it anymore.
sudo passwd -l testuser
To unlock it :
sudo passwd -u testuser
