in the Linux each user in must belong to a group and cannot be independent of the group. Each file in Linux has the concept of owner, group, other group
In a Linux system, the user account that is created and its associated information (except for passwords) are stored in the/etc/passwd configuration file. Because all users have read permissions to the passwd file, the password information is not stored in the file, but is saved in the/etc/shadow configuration file.
1, in the passwd configuration file, the corresponding relationship of the fields from left to right and their meanings:
650) this.width=650; "Src=" Https://s5.51cto.com/oss/201711/19/4747b19ef23dc8f1e7d465885c99ed08.png-wh_500x0-wm_3 -wmp_4-s_1033190526.png "title=" S.png "alt=" 4747b19ef23dc8f1e7d465885c99ed08.png-wh_ "/>
2, user password management
In the shadow configuration file, the corresponding relationship of the fields from left to right and their meanings:
650) this.width=650; "Src=" Https://s3.51cto.com/oss/201711/19/483f0ac3901fe7260215ff4aa179e799.png-wh_500x0-wm_3 -wmp_4-s_4250907418.png "title=" Shd.png "alt=" 483f0ac3901fe7260215ff4aa179e799.png-wh_ "/>
3. Group Information Management files
650) this.width=650; "Src=" Https://s1.51cto.com/oss/201711/19/82276295a8053b7a6d9262ffc3ce12c2.png-wh_500x0-wm_3 -wmp_4-s_3829598291.png "title=" group 2.png "alt=" 82276295a8053b7a6d9262ffc3ce12c2.png-wh_ "/>
User Management commands:
Add user command: Useradd
Modify user command: passwd
Modify User rights: Usermod
Delete User: Userdel
Switch User: Su
A template file home directory is generated when a user is added
/etc/skel
When a user is created, the files are automatically copied in their home directory (based on the template (Files under the template directory))
usermod [Options] User name
-U uid modifies the UID number of the user
-C User Description Modify User's description information
-G Group name Modify User's additional group
-G initial Group modified initial Group
- L temporary lock User (lock)
- u unlock user lock (Unlock)
Example: Adding Harry to the admin group
[[email protected] app] #usermod-G admin Harry
[[email protected] app] #id Harry
uid=1002 (Harry) gid=1003 (Harry) groups=1003 (Harry), 1006 (admin)
3. modifying user information Usermod
Modify user password status chage
usermod [options] User name
-u UID Modified user uid number
-c User Description Modify User's description information
-g Group name Modify user's additional group
-g Initial group Modify initial group
-l temporary lock User (lock)
-u Unlock user lock (Unlock)
Modify User Password status
chage [Options] User name
-l lists the user's detailed password status
-D Date Change Password last modified date (third field of shadow)
-m number of days two password modification interval (Shadow fourth field)
-m number of days password expiration (5th field)
-W Number of days before password expiration warning (6th field)
-I days Grace days after password expires (7th field)
-e Date Password Expiration time (8th field)
User Group Management
1. Add a user group
Groupadd [Options] Group name
-G GID: Specify Group ID
2. Modify user groups
Groupmod [Options] Group name
-G GID: Modify Group ID
-N New group name: Modify Group name
Groupmod-n Newgroup_name Group_name
Change the group name Group_name to Newgroup_name
3. Delete a group name
Groupdel Group Name
This group cannot be deleted when the group is the initial group of a user and the user exists
You have to delete the initial user first.
Groups with additional users who do not have an initial user can delete
Groupadd Gr1
Useradd-g Gr1 U1
Useradd-g Gr1 U2
Does not produce U1 group, U1 user's initial group is GR1.
4. Add users to or remove from a group
GPASSWD [Options] Group name
-A user name: Add user to Group (add-on user)
-D Username: Remove the user from the group
Linux user groups and Rights management