1. Users and user groups
User and User group concepts
User: The person using the operating system (Linux supports multiple users logging on to the same operating system at the same time)
User groups: A group of users with the same permissions (multiple user groups can exist on a Linux system)
Related configuration Files
/etc/group: Stores all user group information in the current system
GROUP:X: 123:abx,def,xyz
Group name: group Password placeholder: Group number: List of users in the group
1. In Linux, the root user group number must be 0
2. Group number 1~499 is the group number reserved by the system, generally reserved for the software or services installed in the operating system, such as the installation of the MySQL database on the server, then the user group will automatically create a list of users named MySQL group, and in the 1~499 with a number to use, The sooner you install the assigned group number, the smaller
3. The group number of user groups created manually by the user is starting from 500
/etc/gshadow: Stores password information for user groups in the current system
Group: *:: ABX,DEF,XYZ
Group name: Group Password: Group manager: List of users in a group
/etc/passwd: Stores information for all users in the current system
USER:X: 123:456:xxxxx:/home/user:/bin/bash
User name: Password placeholder: User number: User group number: User comment information: Home directory: Shell type
The root user number must be 0.
/etc/shadow: The file that stores the user's password (the general password is encrypted by a one-way encryption method, so the original password is not seen)
User:vf;/zushs. : : : : : :
User name: Password:::::
Commands for user group management
Groupadd groupname: Create a new user group name
Groupmod-n newname oldname: change user group name from Oldname to NewName
Groupmod-g 668 groupname: Change the GroupName group number to 668
Groupadd-g 888 groupname: Create a user group GroupName, and set the group number to 888
Groupdel GroupName: Delete user group GroupName
Users in the user group should be deleted before the user group is deleted, otherwise the information about the user group in the user's profile does not match the real situation, and these users become "Heihu" and may be affected by permissions in subsequent use
GPASSWD GroupName: Change the group password for the GroupName user group
user-managed commands
USERADD-G groupname username: Create a new user username, and the user is placed in the user group GroupName
Useradd-d/home/test Username: When you create a user username, explicitly specify that his personal folder is/home/test, and if not explicitly specified, the/home/username folder is used by default
No user group is specified at this time, and a user group with the same name as the new user is created by default, and the user is placed under the user group
Usermod-c Notes Content Username: Username Modify notes for users
Usermod-l newname oldname: Renaming oldname user to NewName
USERMOD-G groupname Username: Switch username user to groupname user group
Userdel Username: Delete username user, but this does not delete his personal folder and the files in it
Userdel-r Username: Delete username user and delete his personal folder
If one day to maintain the system, do not want to let some users login
In the/etc/directory to create the file Nologin (empty files can, do not need content), can be implemented in addition to users other than user will not be able to land system
Lock and Unlock accounts
PASSWD-L Username: Lock user username to prevent users from deleting their own files
Passwd-u Username: Unlocking username users
PASSWD-D Username: Clear Username account, is this user can login without password
primary and secondary groups
a user can belong to multiple user groups at the same time (only one is the primary group of the user, the other is the user's subordinate group)
Knowledge and commands are barely available at this time, so for the time being no further learning
gpasswd-a username newgroup1, newgroup2 : Add the Username account to the satellite group Newgroup1 and Newgroup2
distinguished from usermod-g groupname username: This command modifies the user's primary group, not the secondary group
gpasswd-d username newgroup1,newgroup2 : Remove satellite group NEWGROUP1 and NEWGROUP2
for username account useradd-g group-g newgroup1, newgroup username : Add primary group groups for users when creating user username, and add satellite groups Groupname1 and groupname2
Switch users
SU Username: switch from current user to username user (if no username, it is equivalent to switch to root user)
User password is required to switch from normal user to other user, but no password is required to switch from root to any user
ID username Command
Display specified user information, including user number, user name
Primary group number and name, subordinate group list
Groups username command
Show all groups where the username user resides
CHFN username command
Set up user profile, enter user profile (birthday, gender ...) Information
Finger username command
Show user details (corresponding to the CHFN command)
Linux Learning 8---(User and user group management)