Abstract:1. Master the user's Add/delete/modify command 2. Master the group's Add/delete/modify command
Group Management
1) groupaddGroupadd is used to add group accounts. The format is as follows: groupadd [-g gid] group where: group: is the name of the group to be added-G: used to specify the GID. By default, add 1 with the largest gid. For example: add a new group leader # groupadd leader # grep leader/etc/groupleader: X: 504: # grep leader/etc/gshadowleader :! ::
2) groupmodGroupmod is used to modify the existing group account of the system. The format is as follows: groupmod [Options] group where: group: is a common option for the group account name to be modified:-g gid: re-assign GID-N new_group: Change the group name new_group. Example: rename the Leader Group to leaders # groupmod-N leaders leader # grep leader/etc/groupleaders: X: 504: change the GID of the Leaders Group to 3000 # groupmod-G 3000 leaders # grep leader/etc/groupleaders: X: 3000:
3) groupdelGroupdel is used to delete a group account that already exists in the system. The format is as follows: groupdel group where: group is the name of the group account to be deleted, for example, deleting the Leaders Group # groupdel leaders # grep leaders/etc/group # grep leaders/etc/gshadow
User Management
1) useraddUseradd is used to add user accounts or set the default information used to add users. Format: Format 1: useradd [Options] Login Format 2: useradd-D Format 3: useradd-d [Options] Description: Format 1: Used to add user accounts, login is in the format of User Logon account 2: used to display the default information format used by adding users 3: used to set the default information used by adding users
Add User option: Option description-u uid specifies the UID of the new user. By default, the current largest UID and 1-g group are used to specify the master Group of the new user-G group1 [, group2 ,... [, Groupn] specifies the new user's additional group-D home_dir specifies the logon directory of the new user-s shell specifies the shell used by the new user. The default value is Bash.
Option for changing the Default User value: the default user data is stored in the configuration file/etc/login. defs and/etc/default/useradd.
Example:1. Create a new user newuser, and create the user's own directory # useradd newuser2, create a new user Tom, at the same time, join the staff additional group # useradd-G staff tom3, create a new user webmaster, do not create the user's own directory, specify the login directory/WWW, add to the Apache additional group # useradd-D/www-m-g Apache webmaster
2) usermodUsermod is used to modify the existing group account of the system. The format is as follows: usermod [Options] login where: login: indicates the option of the user account to be modified: -C,-D,-E,-F,-G,-G,-S, and-u have the same meanings as the useradd option. The following options are added:-l new_login: changing a user login name to a NEW_LOGIN-c comment represents additional information about the user, such as the full name-e expire_date specifies the user's logon expiration time, the format is yyyy-mm-dd-F inactive, which specifies the number of days after the password expires to close the account. The default value is-1, that is, no limit is imposed on-K skel_dir to specify the skel directory, by default, it is stored in/etc/skel/-m to create the directory of the new user. The default value-M is not to create the directory of the new user. The option-B base_dir defines the parent directory of the user's directory. The user name is appended to base_dir to create a new user directory. Of course, this option is invalid when-D is used. -Eexpire_date defines the expiration date of the user account. -F inactive defines how many days after the password expires to close the account. -G group defines the start group name or GID of the new account. The group name must be an existing group name. The GID must also be an existing GID. -S shell defines the shell used by the user by default. -L: Locked User Account-u: unlocked User Account
Example:1. Add newuser2 to the staff group # usermod-G staff newuser22, change newuser's username to newuser1 # usermod-l newuser1 newuser3, lock account newuser1 # usermod-l newuser14, and unbind newuser1 lock # usermod-u newuser1
3) userdelUserdel is used to delete a group account that already exists in the system. The format is as follows: userdel [-R] login where: login: indicates the name of the user account to be deleted-R: deletes the user's own directory and the offline files of mail at the same time, for example: 1. Delete the user webmaster # userdel webmaster2. Delete the user newuser1 and its own directory # userdel-r newuser1