The significance of directory and file permissions in Linux
1、 Meaning of file permissions
r: You can read the specific contents of this document;
w: You can edit the contents of this file, including adding and deleting the specific contents of the file;
x: Files have executable permissions —– note: This is different from window. In win, the executable permissions of files are expressed through extensions, such as exe, bat, etc., but in Linux, the executable permissions of files are determined through this x, which has nothing to do with the file name.
2、 Meaning of directory permissions
r: You can view the complete file list information in this directory.
w: You can make relevant changes to all files and directories in this directory, that is, you can change the structure list under this directory (which should be paid attention to). The specific rights are as follows:
You can create new files or directories in this directory;
You can delete existing files or directories in this directory (no matter what the permissions of the file are, you should pay special attention to this!!!)
You can rename and change the location of files or directories.
x: The directory does not have executable permissions, so the function of X in the directory is to allow other users to enter the directory.
Developeppaer reminds you of the needNote:
There is a problem here. Sometimes when we want to share a file with others (the same group or other), after you change the permission of the file, the other party still can’t see it, because others can’t enter your user home directory. By default, they don’t have X permission. If you open the X permission so that he can see the file, others will enter the directory to view the file or modify the file. If this person thinks the file is good and wants to CP a copy, he does not have permission. He thinks that the directory does not have w permission by default. Here, we should pay special attention: it is best not to directly open w permission, because in this way, others can change the list under this directory at will (including deletion, which is very dangerous). Therefore, we can put a copy of this file CP into the third-party directory with W permission, and the other party can also CP from here, so that our home directory will not be affected.
Here is a funny example. A system administrator created an important. TXT file. In order to prevent others from trying to this file, the administrator set the permission to – Rex ——. The administrator thought it was safe, so he put the file in a directory and thought that even if others saw the file, they could do nothing, However, if the directory has w permission at this time, although others can’t do anything to the file, they have the permission to delete the file, which is fatal.
Let’s introduce it to you The significance of Linux permissions to files and directories
Meaning of permissions to files:
r: The actual contents of this file can be read.
w: You can edit, add or modify the contents of the file (but not delete the file). If you do not have R permission, you cannot w.
x: The file has permission to be executed by the system. Can be deleted.
Permission to directory;
r：read contents in directory。 Indicates that you have permission to read the list of directory structures.
w：modify contents in directory。 Indicates that you have permission to change the directory structure list. For example, create new files and directories; Delete existing files and directories (regardless of the permissions of the file), rename the existing files or directories, and transfer the location of files and directories in the directory
x ：access directory。 The X of the directory represents whether the user can enter the directory, which is called the purpose of the working directory.
The above is the significance of file permissions and directory permissions in Linux and the significance of permissions to file directories. I hope this sharing will be helpful to you.