Permissions relationships for files and directories in Linux

Source: Internet
Author: User
Tags parent directory file permissions

Recently have been learning Linux, the permissions of files and directories have a new understanding, feel like to figure out or need to spend a bit of thought.

Note: 1. The following conditions are only for the owner of the file or directory (U); 2. For EXT4 file systems only

Let's talk about how to create, delete, and modify files on the bottom of the system. The disk is divided into two parts to store files, some of which are stored in the properties of the file (metadata) such as: File size, modification date, permissions, etc., the other part is the data content. When you create a new file, it corresponds to the metadata that created it, and it assigns a node number (inode) to the file. When looking for this file, it is to find the corresponding node number, and then through the node table to the data storage area to find data feedback to the user. When the delete file is executed, the data block is placed in the free list, and the data is not deleted immediately, but will be overwritten when another file uses the data block.

First of all, the file permissions, relatively simple to understand.

R: Read permission refers to the specific contents of the file, such as what is written in the text file. The "read" Content here does not include the attributes of the file, such as size, modification date, permissions, etc., which are the metadata mentioned above. Because that doesn't belong to the file content.

W: Write permission, edit, modify or add the contents of the file, but do not include deleting the file. (determined by the W permission of the parent directory)

X: Execute permissions. However, having the Execute permission on a file does not necessarily mean that you can execute the file, but also whether you have the X permission of the parent directory.

In short, for the file R, W, X, mainly for the "content of the file", and the existence of the file name is not related. Because the file records the actual data (relative to the directory).

Directory Permissions: (Directory is a folder, also a special kind of file) compared to the file is the actual data, the contents of the main record is the list of file names.

R: Reads the list of directory structures. Like LS. Can see the file name, the properties of the files can not be seen, to see the file attributes also have the file's parent directory has the X permission.

W: Modify the permissions of the directory structure list (and ignore the permissions of the list file). Include: Create new files, directories, delete files, directories, rename files, directories, move files, directories. For example, a normal user has a directory of the W permission (also to have the directory of the X permission), even if the directory has root files, can also be deleted.

X: Meaning whether the user can access the directory, such as a CD. Use this directory as the working directory. If you do not have X permissions for a directory, you cannot switch to that directory, and any files under that directory cannot be viewed, modified, executed, or deleted. (You can see only the file name, provided that you have the R permission of the parent directory).

Permissions relationships for files and directories in Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.