Preface
The previous blog summarized the linux File Management and summarized the linux File Permission management today! (4W1H Mode)
1. For example
(Fig. 1.1)
You are familiar with this figure. Let's talk about permission management!
2. File Types and permissions
Let's take a look at section 1.1 first. Let's look at the first column,
File Type:
-: Common file (f)
D: directory file
B: block Device Files)
C: character device file (character)
L: symbolic link file)
P: Command pipeline file (pipe)
S: socket File)
File Permission:
A total of 9 bits, each with three bits, each with rwx (read, write, and execute). For example, the permission of the message file is rw-r --
As we have mentioned above, the permissions of files are divided into three groups. What do these three groups represent?
Group 1: file owner Permissions
Group 2: permissions of the group to which the file belongs
Group 3: permissions of other users
Now we know that there are three groups of file permissions: You can set rwx (read, write, and execute), so let's take a look at what commands can be used to set these permissions and attributes!
3. Permission-related commands
Chown: Change the file owner
Chgrp: Change the group to which the file belongs
Chmod: changes the file permissions, SUID, SGID, SBIT, and other features
(1). chown
Chown [-R] Account name: group name file or directory options and parameters:
-R: Perform recursive changes, that is, all files under the directory are changed.
For example, chown root install. log
(2). chgrp
Chgrp [-R] dirname/filename... options and parameters:
-R: Perform recursive changes, that is, update all files and directories under the sub-directory to the group.
Example: chgrp test install. log
Note: chown root: root install. log can change the file owner and group (#:#)