Linux "ls-l" File list permissions detailed

Source: Internet
Author: User
Tags readable syslog dmesg

The results of the execution using the LS-L command are as follows (/var/log):

[HTML]
  1. Drwxr-x---2 root adm 4096 2013-08-07 11:03 apache2
  2. Drwxr-xr-x 2 root root 4096 2013-08-07 09:43 AppArmor
  3. Drwxr-xr-x 2 root root 4096 2013-08-07 09:44 apt
  4. -rw-r-----1 syslog adm 16802 2013-08-07 14:30 Auth.log
  5. -rw-r--r--1 root root 642 2013-08-07 11:03 Boot.log
  6. Drwxr-xr-x 2 root root 4096 2013-08-06 18:34 Consolekit
  7. Drwxr-xr-x 2 root root 4096 2013-08-07 09:44 Cups
  8. -rw-r-----1 syslog adm 10824 2013-08-07 11:08 Daemon.log
  9. Drwxr-xr-x 2 root root 4096 2013-08-07 09:45 Dbconfig-common
  10. -rw-r-----1 syslog adm 21582 2013-08-07 11:03 Debug
  11. Drwxr-xr-x 2 root root 4096 2013-08-07 09:45 Dist-upgrade
  12. -rw-r--r--1 root adm 59891 2013-08-07 11:03 DMESG
Drwxr-x---2 root              adm    4096 2013-08-07 11:03 apache2drwxr-xr-x 2 root              root   4096 2013-08-07 09:43 Apparmordrwxr-xr-x 2 root              root   4096 2013-08-07 09:44 apt-rw-r-----1 syslog            adm   16802 2013-08-07 14:30 auth.log-rw-r--r--1 root              root    642 2013-08-07 11:03 boot.logdrwxr-xr-x 2 root              root   4096 2013-08-06 18:34 Consolekitdrwxr-xr-x 2 root              root   4096 2013-08-07 09:44 cups-rw-r-----1 syslog            adm   10824 2013-08-07 11:08 daemon.logdrwxr-xr-x 2 root              root   4096 2013-08-07 09:45 dbconfig-common-rw-r-----1 syslog< C18/>adm   21582 2013-08-07 11:03 debugdrwxr-xr-x 2 root              root   4096 2013-08-07 09:45 dist-upgrade-rw-r--r--1 root              adm   59891 2013-08-07 11:03 DMESG

The display results are broadly divided into seven columns (partial):

Take the first record as an example

[HTML]
    1. First column: "Drwxr-x---" the type of document and file permissions
    2. Second column: "2" is a pure number, indicating the number of file links
    3. Third column: "Root" indicates the owner of the file
    4. Fourth column: "ADM" as the group where the files are located
    5. Fifth column: "4096", expressed as file length (size)
    6. Sixth column: "2013-08-07 11:03", indicating the last update (modification) time of the file
    7. Seventh column: "Apache2" indicates the name of the file
The first column: "Drwxr-x---" the  type and file permissions of the file The second column: "2" is a pure number, indicating the number of file links in the third column: "Root" means the owner of the file fourth column: "ADM" is represented as the group Fifth column of the file: "4096", expressed as the file length ( Size) column sixth: "2013-08-07 11:03", indicating the last update (modified) time of the file Seventh column: "Apache2" indicates the name of the file


See:

2. File type and file permissions, which is the first column of the list: (Take the first record as an example)

"Drwxr-x---" meaning: There are two parts, part of the first column is "D", the file type (directory or folder), the other part is "rwxr-x---" means the file permissions, the permissions are divided into three paragraphs: that is, "rwx", "r-x" and "---" respectively, the text The permissions of the owner of the file, the rights of the group to which it belongs, and other user permissions on the file.

(1) file types, broadly divided into the following categories:

[HTML]
    1. D: Catalogue
    2. -: File
    3. L: Link
    4. S:socket
    5. P:named Pipe
    6. B:block Device
    7. C:character Device
D: Directory-: File L: Link s:socket p:named pipe b:block device C  : Character device


(2) file permissions:

[HTML]
    1. R: Meaning "readable", denoted by the number 4
    2. W: meaning "writable" is represented by the number 2
    3. X (small X): meaning "executable" is represented by the number 1
    4. -: meaning "no permission" is represented by the number 0
    5. X (large X): The x attribute is appended only if the destination file is executable to some users, or if the target file is a directory.
    6. S: A file in which the owner or group ID of a process is placed at the time of execution of the file. The way "U+s" sets the user ID bit of the file, "G+s" sets the group ID bit.
    7. T: Meaning to save the program's text to the swap device
R: Meaning "readable", denoted by the number 4  w: meaning "writable" with the number 2 means X (small x): meaning "executable" is represented by the number 1-: meaning "no permission" with the number 0 represents X (large X): meaning that only the target file is executable to some users or the target file is a directory plus the X attribute. S: A file in which the owner or group ID of a process is placed at the time of execution of the file. The user ID bit of the "u+s" setting file         , "G+s" sets the group ID bit. T: Meaning to save the program's text to the swap device


3. Changes to file permissions:

Use command: chmod file permissions file name [-R]

Two uses of the command:

(1) Directly assign the appropriate permissions to the file is:

[HTML]
    1. chmod a+x Auth.log #含义为 giving the owner executable permission to the Auth.log file
chmod   a+x  auth.log   

(2) Use digital instead of permissions:

For example:

chmod 777 Auth.log #含义为给auth. log file gives any readable, writable, executable permission

See the following list for the meanings of numbers:

Owner Group Other Number of three-bit delegate permissions
W x    rwx   rw x   actual result
2    421   42 1 777
4 2 1 4 0 1 4 0 1 705

4. Changes to the file owner:

Command chown The user name file, for example:

chmod MySQL auth.log #含义为 Change the owner of the file Auth.log to MySQL

5. Changes to the group where the files are located

Command CHGRP [-r] Group name file name

For example:

Chgrp-r MySQL apache2 #含义为, change the directory apache2 group to MySQL

Linux "ls-l" file list permissions detailed

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.