LINUX: A brief talk on the meaning of directories and common file permissions

Source: Internet
Author: User
Tags compressed file types

directories are identified with the same permission bits as regular files, but their translations are different.

Read Permissions for a directory allow users to list directory contents with this permission.

Write permissions mean that users can use this permission to create or delete files in the directory.

Execute permissions allow the user to enter a directory and access any subdirectory. Without execute permissions, the file system object under the directory is inaccessible.

without Read permissions, the file system objects under the directory are not visible under the directory list, but they are still accessible if you know the full path of the objects on the disk.

The directory is not the same as the normal file permissions, because the directory is not the same as the data recorded by the file.

permissions for normal files:
R (Read): Allow Read permissions, such as the ability to read the contents of a file using a command such as Cat <file name>
W (write): Allow Write permission, indicating that you can edit and modify the contents of a file

X (Execute): Permission to execute, typically a binary program file or script file that can be run.

The type of file is not differentiated by file suffix on Linux. In Linux, the file can be executed by the "X" this permission to determine, and the file extension (mainly depends on the files command) does not have a half-penny relationship. But having the ability to execute, and the success of being able to do it, is two things.


However, the permission bit for the directory is easily confused, here to distinguish:

Permissions for the directory:

R (Read contents in directory): reads the contents of the directory. You can use the LS command to enumerate directory contents, so when you have permission to read a directory, you can query for files in that directory.

W (Modify contents of directory): Edit the contents of the directory.

Have permissions to change the directory structure list:

mainly include:
1. Create new files and directories
2. Delete files and directories under directory (regardless of permissions on the file can be manipulated)
3. Renaming files and directories inside the directory

4, the location of files and directories in the mobile directory

X (Access directory): represents whether the user can enter the directory to become the working directory (CD command).

Note: Directories must have both read and Execute permissions to open, and a directory with write permission to allow other files to be created, because the catalog file actually holds information such as a list of files in that directory

To edit the contents of a file, you must have RW permissions on the file.

To edit directory content, you must have WX permissions on the directory.


Linux Judging file type: (as if the bottom is relying on magic number detection method )

The Linux file command is used to determine the file type by probing the contents of the files, using the permissions of all users. The file command can tell if one of the files is a binary executable or a shell script file, or another format in which file can recognize files including directories, shell scripts, English text, binary executables, C-language source files, text files, DOS-aware files, and so on.


The format of the file command is the file "option" filename

The main parameters of the options are

-V Displays version information after the standard output and launches

-Z Probe for compressed file types

-L Allow connection compliance

-F Name reads the list of file names to parse from the file NameFile



LINUX: A brief talk on the meaning of directories and common file permissions

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.