10.1 Basic introduction to Linux groups
Every user in linux must belong to a group and cannot be independent of the group. In Linux, each file has the concept of owner, group, and other groups.
(1) Owner
(2) The group you belong to
(3) Other groups
(4) Change where the user is located
10.2 File/Directory Owner
Generally, it is the creator of the file. Whoever creates the file naturally becomes the owner of the file.
10.2.1 View the owner of a file
(1) Command: ls -ahl
(2) Application examples
10.2.2 Change file owner
(1) Command: chown username filename
(2) Application case
10.3 Group Creation
(1) Instruction: groupadd group name
(2) Application examples
10.4 Group of files/directories
When a user creates a file, the default group of the file is the group of the user.
10.4.1 View the group where the file/directory is located
(1) Basic command: ls -ahl
10.4.2 Modify the group where the file is located
(1) Command: chgrp group name file name
(2) Application examples
10.5 Other groups
Except for the owner of the file and the user of the group in which it is located, other users of the system are other groups of the file.
10.6 Change user group
When adding a user, you can specify which group to add the user to, and you can change a user's group with root's administrative authority.
10.6.1 Change user group
(1) usermod -g group name username
(2) usermod -d directory name username Change the initial directory where the user logs in
10.6.2 Application Examples