You can manage linux users and user groups to help beginners. 1. add the user syntax: useradd [option] [user account] parameter: -c: specifies a descriptive description.-d: specifies the starting directory for user logon.-g: specifies the group to which the user belongs... capital
Nothing left to worry about. sort out linux User and user group management, hoping to be useful to beginners.
1. add a user
Syntax: useradd [option] [user account]
Parameters:
-C: specifies an annotation description.
-D specifies the starting directory for user login
-G: specifies the group to which the user belongs.
-G user group. The user group specifies the additional owner of the user.
-S specifies the SHELL for user login
-U: User ID of the specified user
Eg:
Useradd-u 501-g 501-G games-d/home/apple-c "apple"-s/bin/bash apple
In the preceding example, the user apple is created, UID = 501, GID = 501, group games are appended, and the default logon Directory of the user is/home/apple, and SHELL is bash.
2. delete a user
Syntax: userdel [-r] [user account]
Note: userdel can delete user accounts and related files. If no parameter is added, only the user account is deleted, and related files are not deleted.
Parameters:
-R: delete the user logon directory and all files in the directory.
Eg:
Userdel apple ----- indicates that only users are deleted.
Userdel-r apple ----- indicates that files related to the apple account are deleted when the user account is deleted.
3. modify a user
Function description: modify a user account.
Syntax: usermod [-LU] [-c <备注> ] [-D <登入目录> ] [-E <有效期限> ] [-F <缓冲天数> ] [-G <群组> ] [-G <群组> ] [-L <帐号名称> ] [-S ] [-U ] [User account]
Note: usermod can be used to modify user account settings.
Parameters:
-D logon Directory> modify the directory when a user logs in.
-E <有效期限> Modifies the validity period of an account. Followed by the date parameter format is MM/DD/YY or YYYY-MM-DD or YYMMDD, note that the unit is day.
-G <群组> Modify the group to which the user belongs.
-G <群组> Modify the additional group to which the user belongs.
-L <帐号名称> Modify the account name.
-L lock the user password to make it invalid.
-U unlocks the password.
-S Modify the shell used after the user logs in.
-U Modify the user ID.
-F <缓冲天数> The account is closed after the password expires. When the followed value is 0, the account immediately becomes invalid. if the value is-1, this function is disabled. the default value is-1.
4. function description: user password management
Syntax: passwd option [user account]
-L lock the password to disable the account
-U password unlock
-D. The account has no password.
-F forces the user to change the login password upon next login
5. function description: add a new user group
Syntax: groupadd option User Group
-G GID: specifies the group ID of the new user group.
-O is generally used together with the-g option. Indicates that the new user group ID can be the same as the group ID of an existing user.
-R: ID of the group to be added, which is lower than the 499 system account.
Eg:
Create a new group and set the group ID to the system:
# Groupadd-g 488 banana
In this case, a group ID (GID) of 488 is generated in the/etc/passwd file.
6. function description: delete a user group.
Syntax: groupdel User Group
The groupdel command modifies the system account and deletes all existing group. group names.
You must manually check all the file systems to make sure there are any files or the group name is changed to the group ID.
If the user of any group is online, the group cannot be removed. It is best to remove the user before removing the group.
7. function description: modify user group information
Syntax: groupmod [-g <群组识别码> <-O>] [-n <新群组名称> ] [Group name]
Note:
You can use the groupmod command to change the group identifier or name.
Parameters:
-G <群组识别码> Set the group ID to be used.
-O reuse the group ID.
-N <新群组名称> Set the group name to be used
Author techcurman