Linux under usermod command detailed
Command: Usermod
Function Description: Modify user account.
Syntax: Usermod [-lu][-c < remarks >][-d < login directory >][-e < expiration >][-f < buffer days >][-g < group >][-g < group >][-l & lt; account name >][-s <shell>][-u <uid>][user Account]
Additional note: Usermod can be used to modify the user account settings.
-c< Notes > Modify the Notes text for the user account.
-D Login Directory > Modify user login directory.
-e< Expiration date > Modify the expiration date of the account.
-f< Buffer days > Modify the number of days after the password expires to close the account.
-g< Group > Modify the group to which the user belongs.
-g< Group > Modify the additional groups to which the user belongs.
-l< Account name > Modify user account name.
-L LOCKS the user password to invalidate the password.
-S modifies the shell used by the user when they log in.
-U modifies the user ID.
-U unlocks the password.
Usermod does not allow you to change the user account name on the line. When Usermod is used to change the user ID, it must be confirmed that the user is not executing any programs on the computer. You need to manually change the user's crontab file. You also need to manually change the user's at work file. Using NIS server requires that the relevant NIS settings be changed on the server.
Options and Parameters:
-C: Follow the account description, that is,/etc/passwd the fifth column of the description bar, you can add some account description.
-D: Back to the home directory of the account, that is, modify the sixth column of/etc/passwd;
-E: followed by the date, the format is Yyyy-mm-dd is the eighth field in the/etc/shadow information!
-F: After the number of days, the seventh column of Shadow.
-G: After the initial group, modify the fourth field of/etc/passwd, that is, the GID field!
-G: Follow the secondary group, modify the user can support the group, modified is/etc/group ~
-A: With-G, you can ' add support for secondary groups ' instead of ' Settings ' Oh!
-L: followed by the account name. That is, modify the account name,/etc/passwd the first column!
-S: followed by the Shell's actual files, such as/bin/bash or/BIN/CSH, and so on.
-U: After the UID number! That is, the information in the third column of/etc/passwd;
-L: Temporarily freezes the user's password so that he cannot log in. In fact, only change the/etc/shadow password bar.
-U: Will/etc/shadow the password bar! Take it off, thaw it!
Example one: Modify the description bar of the user Vbird2, plus the description of ' Vbird ' s test '.
[Email protected] ~]# usermod-c "Vbird ' s test" Vbird2
[[email protected] ~]# grep vbird2/etc/passwd
Vbird2:x:700:100:vbird ' s Test:/home/vbird2:/bin/bash
Example two: The user vbird2 password expires in 2009/12/31.
[Email protected] ~]# usermod-e "2009-12-31" Vbird2
[[email protected] ~]# grep vbird2/etc/shadow
vbird2:$1$50mnwnfq$ochx.0tpancq7ece4hyei.:14301:0:60:7:10:14609:
Example three: When we set up Vbird3 this system account and did not give home directory, please set up his home directory
[Email protected] ~]# ll-d ~vbird3
LS:/home/vbird3:no such file or directory <== confirm that there is no home directory!
[Email protected] ~]# cp-a/etc/skel/home/vbird3
[Email protected] ~]# chown-r vbird3:vbird3/home/vbird3
[Email protected] ~]# chmod 700/home/vbird3
[Email protected] ~]# ll-a ~vbird3
DRWX------4 vbird3 vbird3 4096 Sep 4 18:15. <== User Home directory permissions
Drwxr-xr-x root root 4096 Feb 26 11:45..
-rw-r--r--1 vbird3 vbird3. bash_logout
-rw-r--r--1 Vbird3 vbird3 176. Bash_profile
-rw-r--r--1 Vbird3 vbird3 124. BASHRC
Drwxr-xr-x 3 vbird3 vbird3 4096 Sep 4 18:11. KDE
Drwxr-xr-x 4 vbird3 vbird3 4096 Sep 4 18:15. Mozilla
# chown-r is used to change the meaning of the user/group attributes under the home directory.
# using chmod without-r is because we only need to modify the permissions of the directory instead of the internal file!
This article is from the "Dragon" blog, make sure to keep this source http://1208073155.blog.51cto.com/9039381/1432827