Skip to content

ITrepo Consulting

  • About
  • Blog
ITrepo Consulting

Tag: account management

Linux user account management

Posted March 15, 2019March 15, 2019 masoudPosted in Linux

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