Linux User and user group management tutorial, linux User Group
1. etc/passwd, etc/group, and etc/shadow
Two important files in linux. If the two files are not found or damaged, they cannot be logged on to the linux system.
Etc/passwd this file is divided into seven fields, the specific meaning of each field is as follows:
(1) User name: letters, numbers, underscores, and minus signs
(2) x: stores the user's password. In the early linux system, the password was stored here, but it was only replaced by 'X' for security reasons, the actual encrypted password is stored in the/etc/shadow file.
(3) uid: User ID. The value range is 0---65535. 0 indicates the Super User root, Which is retained by the system 1--499. The general user UID starts from 500.
(4) gid: group ID, corresponding to a record in/etc/group
(5) Notes
(6) user's home directory. After login, the root user's home directory is/root.
(7) shell type, such as bash, sh, csh, ksh, and tcsh. sbin/nologin indicates that this account is not allowed to log on
Etc/shadow this file is divided into nine fields. The specific meaning of each field is as follows:
(1) User Name
(2) User Password, encrypted
(3) last password change time
(4) How many days can I change the password? 0 indicates no limit
(5) How many days must I change the password? 99999 indicates no limit
(6) warning period before Password Expiration
(7) Account expiration period
(8) account Lifecycle
(9) Reserved
In the/etc/group file, linux stores all user group information in this folder and splits it into four fields:
(1) group name
(2) password, which is generally null or *
(3) gid: Group ID
(4) list of all users in this group, separated by commas
2. add or delete a group or user
Groupadd [-g gid] [group name]: If gid is not specified, the system automatically assigns
Groupdel [group name]: deletes a group.
Useradd [-u/g/d/M/s] [user name]: create a user
-U custom uid
-G: Make it belong to an existing group.
-D. Customize the user's home directory
-M does not use Home Directories
-S custom shell Type
Userdel [-r] [user name]: deletes a user.-r indicates that the home directory is deleted together.
Passwd User name: change the password of the user. When you create a user, there is no password by default. Although there is no password, you cannot log on to the system. Only after you create a password can you log on to the system.
Su [user name]: switch user