User management commands in Linux are tools used to create, modify, and delete user accounts and manage user permissions. Here are some commonly used user management commands:
-
useradd: Creates a new user account.sudo useradd username -
usermod: Modifies an existing user account. It can change the username, home directory, shell, and group memberships.sudo usermod -l new_username old_username # Rename user sudo usermod -d /new/home/directory username # Change home directory sudo usermod -aG groupname username # Add user to a supplementary group -
userdel: Deletes a user account.sudo userdel username -
passwd: Changes a user's password.sudo passwd username -
chage: Changes user password expiry information.sudo chage -E YYYY-MM-DD username # Set account expiration date -
id: Displays user and group information for a specified user.id username -
groups: Shows the groups a user belongs to.groups username -
who: Displays who is currently logged in.who -
w: Shows who is logged in and what they are doing.w
These commands are essential for managing user accounts and ensuring proper access control in a Linux environment.
