Skip to content

Usermod command on Linux (changes user data)

The usermod command on Linux modifies the settings of a particular user account.

It accepts the following options:

  • -d home_directory: This option provides the full path to the user’s home directory;
  • -c “username”: This option saves the name of the account owner or any other important note and comment to the passwd file;
  • -g group_number : This option provides the default user account group;
  • -s shell: This option must provide the full shell path used by the account. For example /bin/bash, /bin/tcsh, /bin/false, etc;
  • -L: Lock the user account by adding the “!” sign in the password;
  • -U: Unlock the user’s account by removing the “!” sign of the password.
  • -e 2019-12-31: Indicates that the account must be deactivated on December 31, 2019. The format must be YYYY-MM-DD.

Examples:

Change the comment, with the username Arthur:

# usermod —c “Arthur Ribeiro” Arthur

Lock the user’s Analima account in the system and no longer allow the login:

# usermod —The anime

User Arthur’s account expires on October 31, 2019:

# usermod-e 2019-10-31 Arthur

You can confirm an account’s expiration date with the chage command with the “-l” option:

# chage -l Arthur <br></br>Last password change: Oct 17, 2019 <br></br>Password expires & nbsp;: never <br></br>Password inactive & nbsp;: never <br></br>Account expires & nbsp;: Oct 31, 2019 <br></br>Minimum number of days between password change: 0 <br></br>Maximum number of days between password change: 99999 <br></br>Number of days of warning before password expires: 7

Learn much more about Linux in our online course. You can register here. If you already have an account, or want to create one, just log in or create your user here.

Did you like it?

Share