Linux System Administration

0 of 85 lessons complete (0%)

Managing User Accounts

User Management Commands in Linux

You don’t have access to this lesson

Please register or sign in to access the course content.

CommandPurposeKey OptionsExample
useraddAdd a new user to the system-m (create home dir), -G group (assign to group), -s shell (set default shell)sudo useradd -m -G developers -s /bin/bash john
usermodModify an existing user account-aG group (add to group), -s shell (change shell), -l login (change username)sudo usermod -aG sudo john
passwdChange a user’s password--stdin (provide password through stdin)sudo passwd john
userdelDelete a user account-r (remove home directory)sudo userdel -r john
chageSet or display password aging for a user-l (list info), -M days (maximum days between password changes)sudo chage -M 90 john
whoShow who is logged into the systemNonewho
wShow who is logged in and what they are doingNonew
idDisplay user ID, group ID, and other group membershipsNoneid john
groupsShow the groups a user belongs toNonegroups john
fingerDisplay information about a userNonefinger john
suSwitch to another user- (start login shell), -c command (run command as another user)su - john or su -c "whoami"
sudoExecute a command as another user or as root-u user (run as another user), -i (run as login shell)sudo -u john -i or sudo ls /root
lastShow listing of last logged-in usersNonelast john
lastlogReport the most recent login of all users-u user (check specific user)lastlog -u john
whoamiDisplay the current logged-in user’s usernameNonewhoami
adduserAdd a user (alternative to useradd, simpler UI)Nonesudo adduser john
deluserDelete a user (alternative to userdel)Nonesudo deluser john