The usermod command in Linux is used to modify user accounts. It allows administrators to change various attributes of a user account, such as:
-
Adding a User to a Group: Use the
-aGoption to append a user to a supplementary group.sudo usermod -aG groupname username -
Changing the User's Home Directory: Use the
-doption to specify a new home directory.sudo usermod -d /new/home/directory username -
Changing the User's Login Name: Use the
-loption to change the username.sudo usermod -l newusername oldusername -
Changing the User's Shell: Use the
-soption to specify a new login shell.sudo usermod -s /path/to/new/shell username -
Locking or Unlocking an Account: Use the
-Loption to lock and-Uto unlock a user account.sudo usermod -L username # Lock sudo usermod -U username # Unlock
Overall, usermod is a powerful tool for managing user accounts and their properties in a Linux environment.
