1. Basic introduction, schematic diagram:
illustrate:
-
Linux system is a multi-user and multi-task operating system. Any user who wants to use system resources must first apply for an account to the system administrator, and then enter the system as this account.
-
A linux user needs to belong to at least one group.
2. Add users
2.1 Basic syntax:
useradd [options] username
2.2 Application case:
add a user xm
2.3 Details
-
When the user is successfully created, a home directory with the same name as the user will be automatically created
-
You can also specify a directory through useradd -d, a new user name, and specify a home directory for the newly created user
3. Specify/modify password
3.1
Basic syntax:
passwd username
3.2 Application case:
Specify a password for xiaoming
Notice:
-
At work, passwords must be complex
-
When using passwd to specify a password, the interface is invisible
4. Delete user
4.1 Basic syntax
userdel username
4.2 Application Cases
1. Delete the user xiaoming, but keep the home directory
2. Delete user xq and user home directory
4.3 Thinking
When deleting a user, we generally do not delete the home directory
5. Query user information
5.1 Basic syntax
id username
5.2 Application Examples
Case 1: Please query root information
5.3 Details
-
When the user does not exist, return "no such user"
6. Switch users
6.1 Introduction
In operating linux, if the current user has insufficient permissions, you can switch to a high-privileged user, such as root, through the su - command.
6.2 Basic syntax
su - switch username
6.3 Application Examples
1. Create a user xf, specify a password, and then switch to xf.
6.4
Details
-
Switching from a user with high authority to a user with low authority does not require entering a password, and vice versa.
-
When you need to return to the original user, use the exit command
7. User group
7.1. Introduction
Similar to the monthly role, the system can manage multiple users with common features in a unified manner.
7.2. Adding groups
groupadd group name
7.3. Case demonstration
8. Delete group
8.1
Instructions (Basic Syntax)
groupdel group name
8.2
Case Demonstration
9. Add groups directly when adding users
9.1.
Instructions (basic syntax)
useradd -g user group username
9.2. Case demonstration
Add a user zwj and assign him directly to the wudang group
Steps to see the demo:
10. Modify the user's group
10.1. Instructions (basic syntax)
usermod -g user group username
10.2. Case demonstration
Create a shaolin group and modify the zwj user to the shaolin group
11. User and group related files
11.1 /etc/passwd file
The user's configuration file records various information about the user.
Meaning of each line: Username: Password: User ID: Group ID: Commentary Description: Home Directory: Login Shell
11.2
/etc/shadow file
password configuration file
Meaning of each line: Login Name: Encrypted Password: Last Modified Time: Min Interval: Max Interval: Warning Time: Inactivity Time: Expiration Time: Flag
11.3 /etc/group file
The configuration file of the group (group) records the information of the groups included in Linux
The meaning of each line: Group Name: Password: Group ID: List of users in the group