The article directories
- 1. Basic introduction to Linux groups
- 2. File/directory owner
-
- 2.1 Viewing the File Owner
- 2.2 Changing the File Owner
- 3. Create a group
-
- 3.1 Basic Instructions
- 4. Group where the file or directory resides
-
- 4.1 Viewing the Group where a File or Directory Resides
- 4.2 Modifying the Group where a File or Directory Resides
- 5. Other groups
- 6. Change the user group
-
- 6.1 Changing a User Group
1. Basic introduction to Linux groups
Each user in Linux must belong to a group and cannot be independent of the group. In Linux each file has a concept of owner, group, and other groups.
- The owner of the
- Where the group
- Other groups
- Change the user group
2. File/directory owner
- The creator of the file, who created the file, is the natural owner of the file.
2.1 Viewing the File Owner
- Instructions:
ls -ahl
- Examples of application
2.2 Changing the File Owner
- Instructions:
Chown User name Name of the file
- The application case
- Requirements: Use
root
Create a fileapple.txt
And then change its owner totom
(If the Tom user is created)
chown tom apple.txt
Copy the code
3. Create a group
3.1 Basic Instructions
Groupadd group name
- Examples of application
- Create a group,
monster
groupadd monster
Copy the code
- Create a user
fox
And put it intomonster
In the group
useradd -g monster fox
Copy the code
4. Group where the file or directory resides
- When a user creates a file, the group that the file belongs to is the group that the user belongs to (default).
4.1 Viewing the Group where a File or Directory Resides
- Basic instructions:
The ls - ahl
- For example, use
fox
To create a file, see which group the file belongs to?
First switch to the Fox user:su fox
4.2 Modifying the Group where a File or Directory Resides
- Basic instructions:
CHGRP Group name File name
- Application examples:
Create a file as user rootorange.txt
, see which group the file belongs to, and then change the group tofruit
Group.
groupadd fruit
touch orange.txt
- See which group this file belongs to ->
root
组 chgrp fruit
5. Other groups
- All users of the system are other groups of the file except the owner of the file and the users of the group
6. Change the user group
- When adding a user, you can specify the group to which the user is to be added. You can also change the group of a user by using the root management permission.
6.1 Changing a User Group
Usermod -g New group name User name
Usermod -d Directory name User name
Change the initial directory in which the user logs in. Special note: the user needs to have access to the new directory.
- Examples of application
将xdr630
This user is changed from the original group towudang
组
usermod -g wudang xdr630
Copy the code