1.about owners, groups, and others
In a Linux System, each file has a User,Group , and Others three identity permissions configuration. So what do these three identities mean, respectively? What does it mean to configure permissions for these three identities?
(1) File owner (User)
Because Linux Systems support multi-tasking, there are often situations where multiple users use a single Linux system at the same time. So, how to confirm the access control of each user's private files? This is why the file owner exists.
The Linux system provides a user home directory for each user, and the user's home directory is /home/<username>. For example, the /home/lienhua34 is my home directory, in which only I can add files and delete files, others can browse, but can not view the contents of my file according to the specific file permissions.
Each Linux User creates a file that is owned by its owner. If I have a private file, I certainly do not want others to see it, so I put the file in my home directory, and then set the file permissions to only the file owner (that is, myself) to be able to view and modify. Even if other users know I have this file, he can't view, modify, or delete it.
(2) Group (Group)
Imagine a scenario where you are in a team where each member of the team is working on the same Linux machine, a directory of the Linux machine that holds the work documents of your team, How do we implement this permission control when every member of the team should have view and modify the file and not want users outside the team to have access to the machine? This requires the concept of a group.
We can Create a group for the team on a Linux system and add all members of that team to the group. Then the group that belongs to the group is set to the group, and then the group permissions of the file are set to read and write, so all members of the group can be viewed and modified, and users who do not belong to the group do not have this permission.
(3) Other persons (Others)
Users who are not part of the file owner or the group that the file belongs to are others.
Of course, there is a very special super user, root. The user can access All files on the Linux machine.
For a more detailed introduction, you can refer to Bird's-uncle Linux private Cuisine: Users and Groups
2.Modify owners and groups
We can view the properties of the file through ls-l , as shown in
Of these, columns 3 and 4 indicate the owner (LIENHUA34) of the file and theGroup (Lienhua34 ). We can Modify the owner and group of the file separately by Chown and CHGRP.
(1) Modify the group to which the file belongschgrp
CHGRP is the abbreviation for change group . The use of command chgrp is as follows,
CHGRP [-R] GROUP FILE
The group name group to be modified must be a group that already exists, where the- r option recursively modifies the group that belongs to all files and subdirectories under the directory. For example, the following modified file Filea belongs to the group root,
[Email protected]$sudo chgrpRoot filea[sudo] Password forlienhua34: [Email protected]$ls-Ltotal4-rw-r--r--1Lienhua34 Root0Dec A -: -FILEADRWXR-xr-x2Lienhua34 Lienhua344096Dec A -: -Subdir[email protected]$
(2) Modify the file ownerChown
Chown is the abbreviation for change owner . The simple usage of the command chown is shown below,
Chown [-R] Owner[:[group]] FILE
The command chown can also modify the file's owning group (by Jinzhao the colon (:) and the group name after the owner) in addition to modifying the file owner.
Examples:
change the owner of the file Filea to root,
[email protected]$ sudo chown root filea[email protected]$ ls -ltotal 4 -rw-r--r--1 root root 0 Dec 12 18 : 38 fileadrwxr -xr-x 2 lienhua34 lienhua34 4096 Dec 12 18 : 38 subdir
filea lienhua34 lienhua34
sudo Chown ls -41 lienhua34 lienhua34 0: - FILEADRWXR 2 4096 A : SubDir
(done)
#Linux学习笔记 # Linux file owners, groups, and other people