Item-by-item explanation of ls output

The meaning of the ls  command is to list the file names in the current directory. Note that without parameters it displays the names of all files and directories except hidden files.

       1 ) ls -a  displays all files in the current directory, including hidden files

] # ls –a

..gnome2.nautilus                             

..               .gnome2_private     oracle_rpm

.bash_profile    .gtkrc-1.2-gnome2   tnsnames.ora

.bashrc          .ICEauthority       types.h

       Note that hidden files are files whose names begin with " . " (full stop).

      

       2 ) ls -l  shows the files and their details.

] # ls –l

total 5

-rw-r--r--    1 root     root         1668 Oct 3 2007 anaconda-ks.cfg

drwxr-xr-x    2 root     root         4096 Nov 6 00:04 aa

What do the file details displayed mean? Take the blue part above as an example.

total 5  means that the total size of files in the current directory is 5K (the size of each directory is calculated as 4K )

 There are three cases for the first character of drwxr-xr-x : " - " means normal file, " d " means directory, " l " means connection file, " b " means device file.

The next 9 characters are in groups of 3 , which represent the file owner, the user group where the file owner belongs, and the permissions that other users have on the file. The three characters in each group represent read, write , and execute permissions respectively . Execute permission has two characters optional " x " for executable, " s " for socket file .

The next number 2 represents the number of directory files in the " aa " directory (this number = the number of hidden directories + the number of ordinary directories). We enter the " aa " directory with the command  ls –al  (in order to see hidden files we add the -a parameter) 

] # ls -al

total 8

drwxr-xr-x    2 rootroot4096 Nov6 00:04 .              

drwxr-x---   14 root     root         4096 Nov 6 00:04 ..

(The 2 in line 3 above means that there are 2 subdirectories in the current directory , namely . and ..

The 14 in line 4 above means that there are 14 subdirectories in the directory one level above this directory. )

 

The next root represents the owner of this file (directory) as user root 

The next root represents the user group to which this file (directory) belongs is group root 

4096  represents the size of the file (in bytes), the size of a directory is always 4096 bytes.

Nov  6 00:04  represents the modification time of the file (directory).

aa stands for the file (directory) in the name.

 

3 ) The meaning of the color of the file name

默认色代表普通文件。 例:install.log

绿色代表可执行文件。 例:rc.news

红色代表tar包文件。    例:vim-7.1.tar.bz2

       蓝色代表目录文件。    例:aa

       水红代表图象文件。    例:Sunset.jpg

       青色代表链接文件。    例:rc4.d   (此类文件相当于快捷方式)

       黄色代表设备文件。    例:fd0

      

4)几个比较常用的参数。

       -t 按最后修改时间排序。

       -S 按文件大小排序。(大写的S

       -r 排序时按倒序。

       -h 显示文件大小时增加可读性 (例:1K 234M 2G

 

如果这个aa是个普通文件,2就代表这个文件有2个别名(这个文件被人创建了一个硬链接文件)

Guess you like

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