Linux user management operations

  • The 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 from the system administrator, and then enter the system as this account.
  • Linux users need to belong to at least one group

1. Add a user

useradd [options] username

Insert picture description here

  1. When the user is successfully created, a home directory with the same name as the user will be automatically created

  2. You can also specify the new user name of the directory through useradd-d, and specify the home directory for the newly created user

Insert picture description here

2. Assign or modify the password for the user

passwd username

Insert picture description here

delete users

userdel username : delete the user to keep his home directory

userdel -r username : delete the user and the user's home directory

Insert picture description here

Insert picture description here

When deleting a user, we generally do not delete the home directory.

3. Query user information

id username
Insert picture description here

4. Switch users

In operating Linux, when we have insufficient permissions, we can switch to a high-privileged user through su- username

su-username

Insert picture description here

  • Switching from a user with high authority to a user with low authority does not require a password, and vice versa.
  • When you need to return to the original user, use the exit command

5. User group

Similar to roles, the system can perform unified management of multiple users with commonalities.

5.1, add group

groupadd group name

Insert picture description here

5.2, delete group

groupdel group name
Insert picture description here

5.3. Add groups when adding users

useradd -g user group username

Insert picture description here

5.4, ​​modify user group

usermod -g user group username

Insert picture description here

6. /etc/passwd file

  • User (usen) configuration file, which records various user information
  • Meaning of each line: user name: password: user identification number: group identification number: annotation description: home directory: login Shell

vim /etc/passwd

Insert picture description here

7. /etc/shadow file

Insert picture description here

  • Password configuration file
  • Meaning of each line: Login name: Encrypted password: Last modification time: Minimum time interval: Maximum time interval: Warning time: Inactivity time: Expiration time: Sign

8. /etc/group file

Insert picture description here

  • Group (group) configuration file, record the group information contained in Linux
  • Meaning of each line: group name: password: group identification number: list of users in the group

Thank you all for reading! If there is a mistake in the above, please correct it

Recommended learning linux video B station is still Silicon Valley Hanshun Ping teacher

Guess you like

Origin blog.csdn.net/qq_44763720/article/details/108127625