How does the 'usermod' command modify user accounts?

The usermod command in Linux is used to modify user accounts by changing various attributes without deleting and recreating the account. Here are some common options you can use with usermod:

  1. Change Username:

    sudo usermod -l new_username old_username
    
  2. Change Home Directory:

    sudo usermod -d /new/home/directory -m username
    
  3. Add User to Groups:

    sudo usermod -aG groupname username
    
  4. Change Login Shell:

    sudo usermod -s /path/to/new/shell username
    
  5. Set Account Expiration Date:

    sudo usermod -e YYYY-MM-DD username
    
  6. View User Information: You can check the changes by using commands like id, groups, or examining the /etc/passwd and /etc/group files.

These options allow administrators to efficiently manage user accounts in a Linux environment.

0 Comments

no data
Be the first to share your comment!