What does usermod do?

The usermod command in Linux is used to modify user accounts. It allows administrators to change various attributes of a user account, such as:

  1. Adding a User to a Group: Use the -aG option to append a user to a supplementary group.

    sudo usermod -aG groupname username
  2. Changing the User's Home Directory: Use the -d option to specify a new home directory.

    sudo usermod -d /new/home/directory username
  3. Changing the User's Login Name: Use the -l option to change the username.

    sudo usermod -l newusername oldusername
  4. Changing the User's Shell: Use the -s option to specify a new login shell.

    sudo usermod -s /path/to/new/shell username
  5. Locking or Unlocking an Account: Use the -L option to lock and -U to 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.

0 Comments

no data
Be the first to share your comment!