Linux usermod Command: Changing User Settings
Linuxcommands
The usermod command in Linux modifies the settings of a specific user account.
It accepts the following options:
- -d home_directory: This option provides the full path of the user's home directory;
- -c "user's name": This option writes to the passwd file the name of the account owner or any other important remark and comment;
- -g group_number: This option provides the default group of the user's account;
- -s shell: This option must provide the full path of the shell used by the account. For example /bin/bash, /bin/tcsh, /bin/false, etc;
- -L: Locks the user account by adding the "!" sign to the password;
- -U: Unlocks the user account, removing the "!" sign from the password.
- -e 2019-12-31: Indicates that the account should be deactivated on December 31, 2019. The format must be YYYY-MM-DD.
Examples:
Changes the comment, with the user name Arthur:
# usermod –c “Arthur Ribeiro” arthur
Locks the user account analima on the system no longer allowing logon:
# usermod –L analima
Expires the user account arthur on October 31, 2019:
# usermod -e 2019-10-31 arthur
You can confirm the expiration date of an account with the chage command using the "-l" option:
# chage -l arthur Last password change : Oct 17, 2019Password expires : neverPassword inactive : neverAccount expires : Oct 31, 2019Minimum number of days between password change : 0Maximum number of days between password change : 99999Number of days of warning before password expires : 7
Learn much more about Linux in our online course. You can enroll here. If you already have an account, or want to create one, simply log in or create your user here.
Liked it? Share
That was just one piece. The course teaches the whole path — from your first command to exam day.