User information
file: /etc/passwd
Field meaning: 1, account name 2, password 3, UID 4, GID 5, user information description 6, Shell
User password information
File: /etc/shadow
Field meaning: 1. Account name 2. Password 3. Date of last password change 4. Number of days that password cannot be changed 5. Number of days that password needs to be re-changed 6. Number of warning days before password needs to be changed Time 8. Account Expiration Date 9. Retention
User group information
file: /etc/group
Field meaning: 1. User group name 2. User group password (basically useless) 3. GID 4. Account name supported by this user group
User group administrator information
File: /etc/gshadow
Field meaning: 1. User group name 2. Password column 3. User group administrator account 4. Account to which the user group belongs
Create User Defaults
File: /etc/default/useradd
Note: The GROUP=100 setting is invalid for RHEL, Fedora, and CentOS. They create a user group with the same name to the user
effective user group
Description: When a user creates a file, the user group to which the newly created file belongs (can only be switched within the supported user group)
initial user group
User group created by default when creating a user
New users
useradd [-u UID] [-g initial user group] [-G secondary user group] [-mM] [-c description column] [-d absolute path to home folder] [s shell] user account name
-M force not to create user home folder
-m Force creation of user home folder
illustrate:
1. The useradd command will at least refer to the /etc/default/useradd /etc/login.defs /etc/skel/* files when creating a user
2. It mainly creates /etc/passwd, /etc/shadow, /etc/group, /etc/gshadow and user home folders
password setting
passwd [--stdin] username
Note: When using the root account to execute the passwd command to modify other people's accounts, the command must be added with the account name, otherwise it is to modify your own password
View new user default configuration (system administrator)
useradd -D
Modify user information (system administrator)
usermod [cdegGlsuLU] username
Change user secondary user group (system administrator)
usermod -G <group> <user>
Switch effective user group (system administrator)
newgrp <group>
delete user (system administrator)
userdel [-r] username
Note: If you just don't want the user to continue to use it, just change the expiration date (the 8th field) in /etc/shadow to 0
Add a new user group (system administrator)
groupadd [g -gid] [-r] User group name
Modify user group (system administrator)
groupmod [-g gid] [-n groupname] User group name
Delete User Group (System Administrators)
groupdel [groupname]
User group management (system administrator)
gpasswd groupname --indicates giving the user group a password
gpasswd [-A user1 ...] [-M user1 ...] group name
-A Gives the master control to the specified user for management
-M add user to group
User Group Management (User Group Administrator)
gpasswd [-ad] user groupname
-a add the user to the user group
-d remove user from user group
Modify the user group to which the file belongs
chgrp [-R] dirname/filename
-R Recursive modification, that is, the user group of sub-files in the directory is also deleted
Modify the user who owns the file
chown [-R] username dirname/filename
Modify file permissions
chmod [-R] xyz
x: file owner permissions
y: permissions of the user group to which the file belongs
z: Other user rights
Read permission r: 4
Write permission w: 2
Execute permission x: 1