Add user
useradd [options] username
Note: When the user is successfully created, the /home directory directory with the same name as the user will be automatically created.
You can also specify the new user name of the directory through useradd-d to specify the home directory for the newly created user
Assign or modify the password for the user
passwd username
Note: The password cannot be seen when using passwd to specify the password
delete users
userdel [options] username
Note: When you delete users generally want to keep the home directory
can userdel -r 用户名
be deleted with the user and the user's home directory
Query user information
id username
Note: When the user does not exist, return "No such user"
Switch user
su-switch user name
Note: To switch from a user with high authority to a user with low authority, you do not need to enter a password, and vice versa.
When you need to return to the original user, use the exit command
Add group
groupadd group name
Delete group
groupdel group name
Add groups directly when adding users
useradd -g user group username
Modify user's group
usermod -g user group username
Record various information of users and groups
/etc/passwd file
The configuration file of the user (user), which records various user information. The meaning of each line: user name: password: user identification number: group identification number: annotation description: home directory: login Shell
/etc/shadow file
The meaning of each line of the password configuration file: login name: encrypted password: last modification time: minimum time interval: maximum time interval: warning time: inactivity time: expiration time: sign
/etc/group file
The configuration file of group (group), which records the group information contained in Linux. Meaning of each line: group name: password: group identification number: list of users in the group