Add Users:
Useradd Xiaol
-U manually specify the UID number of the user
-D Manually Specify home directory
-C Manually specify the user's description information
-G manually specifying user initial groups
-G Modify User Attach Group
Attention:
Assigning groups when creating a user: Useradd-g group name User name
Useradd-g gp_1 Xiaol_1
Set Password:
passwd Xiaol
-L Lock User
-U Unlock User
To delete a user:
Userdel-r Xiaol
-R Delete user and home directory
To modify a user:
Usermod-c "Good Man" Xiaol
-U Modify UID number of user
-C Modify User's description information
-G Modify User initial Group
-G Modify User Attach Group
-L Temporary Lock user
-U Contact User
To modify the password status:
Chage-m 1 Xiaol
-l lists the user's detailed password status
-D date Change password last changed date
-M days modified two password change interval
-M days Change password validity
-W number of days before the change password expires
-I days modified password expires after the grace days
-e Date Modified account expiration time
Description
Actually, the value in the/etc/shadow file is modified.
The most common usage is chage-d 0 xiaol users need to change their passwords as soon as they log in
To view the user id:
ID Xiaol
uid=500 (Xiaol) gid=500 (XIAOL) group =500 (XIAOL)
To switch users:
Su-user name
-Switch environment variables while switching users
To add a group:
Groupadd gp_1
To modify a group:
Groupmod-n gp_2 gp_1
-N New group name
To delete a group:
Groupdel gp_1
If there are initial users in the group, the group cannot be deleted
If there are no users or only additional users in the group, you can delete
Users in the action group:
To add a user to a group:
GPASSWD-A User Name Group name
To remove a user from a group:
GPASSWD-D User Name Group name
Essence:
Modified the/etc/group this file, the user name is written to the field of additional groups there
Attention:
1. Only the root user or a user with root privileges can operate
2. After adding user success
1. Automatically create a directory with the word Xiaol under/home as the Xiaol user's main directory
2. Under/var/spool/mail/, a directory named Xiaol is automatically created to receive anticipation mail.
3. Write user information within/etc/passwd
4. Write password information within/etc/shadow
5. Write group information within/etc/group
6. Write group password information within/etc/gshadow
7. Copy all files from the/etc/skel directory to the home directory in Xiaol
3. If you want to add or remove users manually, simply write or delete the 1-6 in 2
Linux User Management commands