Under Linux, directories and files will have 3 permissions, namely: Readable R, writable W, can execute x. So what's the difference between a directory and a file's permissions? This is the question that this blog post explains.
Before we explain, we should have some basic knowledge: there are 3 identities (all groups, groups of users, others), 3 permissions (R,W,X), 3 commands to modify permissions (Chown, CHGRP, chmod) under the Linux system.
1.3 Types of permissions for files
1) Read: Can read the contents of the file, such as reading the contents of a text file.
2) Writer: You can edit, add, or modify the contents of a file, but you cannot delete the file . The changes here are based on the contents of the file and the data recorded in the file.
3) Execute: The file can be executed by the system . This needs to be noted, because Linux and Windows systems are not the same. Under Windows systems, whether a file can be executed is distinguished by an extension, such as. exe,. bat,. com, and so on, these file types can be executed, and under Linux, whether the file can be executed by permission X, and the file name does not have an absolute relationship.
2.3 Types of permissions for a directory
1) Read: Has permission to read the directory structure list. indicates that the user can use LS to query a list of files for that directory .
2) Writer: has permission to change the list of this directory structure. You can create new directories and files, delete existing files and directories (regardless of permissions for deleted files), rename existing files and directories, and transfer existing files and directory locations . So the user write permission to the directory is very important, the right is also very big .
3) Execute: The user can enter the directory to become the user's current working directory. That is, you can enter the directory operation by CD .
Brother Bird's book uses an example to illustrate:
Because the directory and file permissions are 744 and rwx for root, you can use LS to see the file list information in the directory.
But for other users, it has only r permission, so can only read the file name of LS, detailed information can not read, as follows:
(PS: But I am under the Vbird user, use Ls-al can see testing details, see Testing file alone does not see)
After that, we can use Chown to modify the permissions of the Vbird user to the testing file as follows:
At this time Vbird user to testing file has rwx permissions, then you can implement Cd,ls-l, RM and so on.
Note that you can delete files in the directory by having W permission on the directory!
Note where mkdir, LS, CD, RM, Chown, Touch (Create an empty file), Su These common commands are used.
Reference:
"Brother Bird's Linux private cuisine-Basic Learning article"
Three types of permissions for directories and files under Linux