usermod Linux Command

What is Linux usermod Command?


usermod COMMAND:

usermod command is used to change or modify the existing user account details using command line.


The syntax is
usermod [options] [username]


-d To modify the directory for any existing user account
-s Create a specified shell for new accounts.
-g Change the primary group for a user.
-G To add a supplementary groups.
-M moving the contents of the home directory from existing home dir to new dir.
-e Specifies the expire date of the user
-u Used to Assigned UID for the user account.
-l To change the login name .
-L To lock the user account details.


  1. To change username:
    usermod -l hiox hioxindia

    This command will modify the user hioxindia to hiox.
  2. To modify user but not allow to login in the system:
    usermod -s /bin/nologin hiox

    Above command will add the user hiox but it wont allow the user to login with the account details.
    In above command:
    hiox-Is the user-name
    /bin/nologin-Is Shell assigned to the user
  3. To modify expire date of the user:
    usermod -e 2008-06-30 hiox

    This command will modify the expire date of hiox to 2008-06-30.
    In above command:
    hiox-Is the user-name
    2008-06-30-Is date on which the user-account will be expired

Ask Questions

Ask Question