User management

From English Wiki
Jump to navigation Jump to search

The following commands are common commands for managing users on a Linux system, particularly in a multi-user or networked Linux environment.


Command Function
chage Set or change password expiration (age) policy
chage -d 0 user Make user password expire (requires user to change password on net logon)
chage -E YYYY-MM-DD user Change password expiry
chage -E0 user Disable account
chage -E1 user Re-enable account
chage -M -W -I -d user Set or change password expiration for user: -M maximum number of days between password changes; -W number of days for user to receive warning before expiration; -I inactive days after password expiration before account is locked; -d days since password was changed (setting to 0 forces password change on next logon)
chfn user Change finger information for a user
finger Display information about a user
grep user /etc/shadow Check account status (! = locked account; !! = password locked)
groupadd group Create a new group
groupdel group Remove a group
groups Shows which groups a user is in
id Display UID and GID of the current user
last Display the last users who have logged onto the system.
grep 'still logged in' Find users who last logged in
lastlog Lists login attempts and times for all users
lslogins Display information on known users
passwd Set or change password
passwd -l user Lock password
passwd -u user Unlock password
quota List user’s quotas
quota List user’s quotas
su user Access superuser privileges
useradd -c "John Smith" -m john Create an account named john, with a comment of "John Smith" and create the user's home directory.
useradd user Add a new user account
userdel -r user Delete a user account
usermod -aG group user Add a user to a specific group
usermod -L user Lock account
usermod option user Change the user account information including, group, home directory, shell, expiration date
users Find users who are logged in
visudo Edit /etc/sudoers file
w Display all users who are logged in to the machine and their active processes
who Display all users who are logged in to the machine
whoami Displays current user



See also