ls Command & File and Directory Properties

file and directory attributes

[root@centos-01 ~]# ls -l
总用量 4
-rw-------. 1 root root 1418 1227 05:29 anaconda-ks.cfg

A total of 9 columns are displayed

  • Column 1 contains the file type and the owner, group, and permissions of other users on the file. The first column has a total of 11 digits (some files have 10 digits, but there is no last digit). The first one is used to describe the type of the file.

file type :

abbreviation meaning
‘d’ Indicates that the file is a directory
‘-’ Indicates that the file is a normal file
‘l’ Indicates that the file is a linked file
‘b’ Indicates that the file is a block device, such as /dev/sda is such a file
‘c’ Indicates that the file is a string device (serial port device) such as keyboard, mouse
‘s’ Indicates that the file is a socket file (socket) for inter-process communication

The next 9 digits are in groups of three. All are a combination of the three parameters of rwx. where r stands for readable, w stands for writable, and x stands for executable. The first three are the permissions of the owner (user), the middle three are the permissions of the group (group) to which they belong, and the last three are the permissions of other non-groups (others). Permissions can also be represented by numbers, r=4, w=2, x=1, rwx=7, rw-=6, –x=1, rw-r–r–=644, rw-r-xr-x=655 .

The '.' (dot) in the last digit of the first column, the previous CentOS 5 did not have this dot, mainly because the new version of ls added the attributes of selinux or acl. Here is a point when a file or directory uses only attributes of the selinux context. If acl is set, it will be followed by a plus sign '+'.

  • The second column represents the node (inode) occupied by the link. When it is a directory, it is usually related to how many directories are under the directory.

  • Column 3 , indicates the owner (owner) of the file

  • The fourth column indicates the group (user group) to which the file belongs

  • Column 5 , indicating the size of the file (unit: B bytes)

  • The 6th , 7th and 8th columns are the most recent modification date of the file, which are the month date and time respectively, which is the so-called mtime

  • Column 9 , filename.


-i: the inode number of the file

[root@centos-01 ~]# ls -i anaconda-ks.cfg 
33582978 anaconda-ks.cfg

-h: Automatically convert the unit, here the size of the file is displayed in KB

[root@centos-01 ~]# ls -lh anaconda-ks.cfg 
-rw-------. 1 root root 1.4K 1227 05:29 anaconda-ks.cfg

-a: View all files and directories in the directory, including hidden ones

[root@centos-01 ~]# ls -la
总用量 28
dr-xr-x---.  3 root root  147 1月   1 10:43 .
dr-xr-xr-x. 17 root root  224 1月  16 18:31 ..
-rw-------.  1 root root 1418 12月 27 05:29 anaconda-ks.cfg
-rw-------.  1 root root 1068 1月  18 17:22 .bash_history
-rw-r--r--.  1 root root   18 12月 29 2013 .bash_logout
-rw-r--r--.  1 root root  176 12月 29 2013 .bash_profile
-rw-r--r--.  1 root root  176 12月 29 2013 .bashrc
-rw-r--r--.  1 root root  100 12月 29 2013 .cshrc
drwx------.  2 root root   48 1月  18 15:40 .ssh
-rw-r--r--.  1 root root  129 12月 29 2013 .tcshrc

Note : One dot "." is the current directory, and two dots ".." are the previous directory.

-t: sort by time

[root@centos-01 ~]# ls -lta
总用量 28
-rw-------.  1 root root 1068 1月  18 17:22 .bash_history
drwx------.  2 root root   48 1月  18 15:40 .ssh
dr-xr-xr-x. 17 root root  224 1月  16 18:31 ..
dr-xr-x---.  3 root root  147 1月   1 10:43 .
-rw-------.  1 root root 1418 12月 27 05:29 anaconda-ks.cfg
-rw-r--r--.  1 root root   18 12月 29 2013 .bash_logout
-rw-r--r--.  1 root root  176 12月 29 2013 .bash_profile
-rw-r--r--.  1 root root  176 12月 29 2013 .bashrc
-rw-r--r--.  1 root root  100 12月 29 2013 .cshrc
-rw-r--r--.  1 root root  129 12月 29 2013 .tcshrc
[root@centos-01 ~]# ls -la
总用量 28
dr-xr-x---.  3 root root  147 1月   1 10:43 .
dr-xr-xr-x. 17 root root  224 1月  16 18:31 ..
-rw-------.  1 root root 1418 12月 27 05:29 anaconda-ks.cfg
-rw-------.  1 root root 1068 1月  18 17:22 .bash_history
-rw-r--r--.  1 root root   18 12月 29 2013 .bash_logout
-rw-r--r--.  1 root root  176 12月 29 2013 .bash_profile
-rw-r--r--.  1 root root  176 12月 29 2013 .bashrc
-rw-r--r--.  1 root root  100 12月 29 2013 .cshrc
drwx------.  2 root root   48 1月  18 15:40 .ssh
-rw-r--r--.  1 root root  129 12月 29 2013 .tcshrc

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325729644&siteId=291194637