9.4 "Linux learning is not difficult" user management (5): Modify the Linux user account
Use the Usermod command to change the user's shell type, the group to which it belongs, the lifetime of the user's password, and the user's login name.
Command syntax:
usermod [Options] [user name]
The meanings of the options in the command are as shown in the table.
Options |
option meaning |
-G < secondary Group name > |
Modify the secondary group to which the user belongs (additional group) |
-L < new sign-in name > |
Modify user account name |
-L |
Lock the user password to invalidate the password |
-S <shell type > |
After you modify the user login, use the Shell. if not, the system will use the system preset Shell |
-U |
Unlock Password |
-U < user uid> |
Modify User Uid |
-C < username Full name > |
Modify the user name of the user account |
-D < home directory > |
Modify the home directory when the user logs on, If you specify the-m option, the user's old directory is moved to a new directory, and the legacy directory does not exist, the new directory |
-E < expiry date > |
Modify the validity period of the account, plus the user account stop date, the date format is Mm/dd/yy |
-F < expiry date > |
Modify the number of days after the password expires to set the password to fail state |
-G < main group name > |
Modify the primary group to which the user belongs, The cluster name must already exist |
-O |
allows the use of duplicate Uid |
-M |
Move the contents of the home directory to a new location |
Example: Modify the user Wangwu's home directory to/home/opop, and create the/home/opop directory automatically.
[Email protected] ~]# usermod-d/home/opop-m Wangwu
Example: Modify the user Wangwu login name to Zhaoliu.
[Email protected] ~]# usermod-l Zhaoliu Wangwu
Example: Modify user Zhangsan To disable the account 20 days after the password expires.
[Email protected] ~]# usermod-f Zhangsan
Example: To modify the primary group that the user Zhangsan belongs to is root, the group must exist beforehand.
[Email protected] ~]# usermod-g root Zhangsan
Example: Lock the user Zhangsan password to invalidate the password.
[Email protected] ~]# usermod-l Zhangsan
Example: Unlock user zhangsan password.
[Email protected] ~]# usermod-u Zhangsan
Example: the shell type to modify user Zhangsan is/bin/ksh.
[Email protected] ~]# usermod-s/bin/ksh Zhangsan
This article extracts from "Linux Learning is not difficult" textbook, which is one of the most practical, theoretical and practical Linux Introductory materials. To read the entire book, visit the Linux ops (www.linuxywz.com) website .
Linux learning is not difficult user management (5): Modify Linux User accounts