Linux第一周学习笔记(12)


2.3:ls命令

ls –l命令:列出文件详细信息

ls –i命令查看inode

ls –lh命令:查看文件大小

ls –la命令:查看所有文件以及隐藏的文件

ls –lt命令:按时间的顺序排序

ls –ld命令:只列目录本身(d不加把目录下面的文件及目录列出来)

which ll命令:查看别名

llls –l的一个别名

2.4:文件类型

使用ls -l命令查看文件后,在左侧的第一列第一位表示设备类型

  1. d:表示目录

  2. -:表示普通文件(包含文本文档及带色标记的二进制文档)

  3. c: 表示字符串的设备(如:鼠标、键盘)

  4. L:软件连接或者硬连接文件(软连接相当于一个快捷方式)

  5. s:通讯文件(如:进程相互间的通讯)

cat命令:可查看普通文本文档,带色标记的二进制文档不能打开

-------------------------------------------------------------------------------------------------------------------

-rw-------. 1 root root 1418 1  22 08:19 anaconda-ks.cfg

-rw-------(权限).1(有多少个文件使用了相同的inode)root(表示所有者是) root(所属组) 1418(文件大小1.4k 1  22 08:19(文件创建时间) anaconda-ks.cfg(文件名)

--------------------------------------------------------------------------------------------------------------------

[root@daizhihong01 ~]# ls -i anaconda-ks.cfg

33581218 anaconda-ks.cfg

---------------------------------------------------------------------------------------------------------------------

 [root@daizhihong01 ~]# ls -lh anaconda-ks.cfg

-rw-------. 1 root root 1.4K 1  22 08:19 anaconda-ks.cfg

[root@daizhihong01 ~]# ls -la

总用量 28

dr-xr-x---.  3 root root  147 1  24 22:37 .

dr-xr-xr-x. 17 root root  265 1  24 22:48 ..

-rw-------.  1 root root 1418 1  22 08:19 anaconda-ks.cfg

-rw-------.  1 root root  935 1  26 05:47 .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  26 04:29 .ssh

-rw-r--r--.  1 root root  129 12 29 2013 .tcshrc

[root@daizhihong01 ~]# ls -lta

总用量 28

-rw-------.  1 root root  935 1  26 05:47 .bash_history

drwx------.  2 root root   48 1  26 04:29 .ssh

dr-xr-xr-x. 17 root root  265 1  24 22:48 ..

dr-xr-x---.  3 root root  147 1  24 22:37 .

-rw-------.  1 root root 1418 1  22 08:19 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@daizhihong01 ~]# ls -la

总用量 28

dr-xr-x---.  3 root root  147 1  24 22:37 .

dr-xr-xr-x. 17 root root  265 1  24 22:48 ..

-rw-------.  1 root root 1418 1  22 08:19 anaconda-ks.cfg

-rw-------.  1 root root  935 1  26 05:47 .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  26 04:29 .ssh

-rw-r--r--.  1 root root  129 12 29 2013 .tcshrc

[root@daizhihong01 ~]# ls -d /root/

/root/

[root@daizhihong01 ~]# ls -l /root/

总用量 4

-rw-------. 1 root root 1418 1  22 08:19 anaconda-ks.cfg

[root@daizhihong01 ~]# ls -ld /root/

dr-xr-x---. 3 root root 147 1  24 22:37 /root

[root@daizhihong01 ~]# ls -l

总用量 4

-rw-------. 1 root root 1418 1  22 08:19 anaconda-ks.cfg

[root@daizhihong01 ~]# ll

总用量 4

-rw-------. 1 root root 1418 1  22 08:19 anaconda-ks.cfg

-------------------------------------------------------------------------------------------------------------

[root@daizhihong01 ~]# which ll

alias ll='ls -l --color=auto'

       /usr/bin/ls

--------------------------------------------------------------------------------------------------------------

-----------------------------------ls命令参数-----------------------------------------------------------------

 

-a:显示所有档案及目录(ls内定将档案名或目录名称为“.”的视为影藏,不会列出);

-A:显示除影藏文件“.”和“..”以外的所有文件列表;

-C:多列显示输出结果。这是默认选项;

-l:与“-C”选项功能相反,所有输出信息用单列格式输出,不输出为多列;

-F:在每个输出项后追加文件的类型标识符,具体含义:“*”表示具有可执行权限的普通文件,“/”表示目录,“@”表示符号链接,“|”表示命令管道FIFO,“=”表示sockets套接字。当文件为普通文件时,不输出任何标识符;

-b:将文件中的不可输出的字符以反斜线“”加字符编码的方式输出;

-c:与“-lt”选项连用时,按照文件状态时间排序输出目录内容,排序的依据是文件的索引节点中的ctime字段。与“-l”选项连用时,则排序的一句是文件的状态改变时间;

-d:仅显示目录名,而不显示目录下的内容列表。显示符号链接文件本身,而不显示其所指向的目录列表;

-f:此参数的效果和同时指定“aU”参数相同,并关闭“lst”参数的效果;

-i:显示文件索引节点号(inode)。一个索引节点代表一个文件;

--file-type:与“-F”选项的功能相同,但是不显示“*”;

-k:以KB(千字节)为单位显示文件大小;

-l:以长格式显示目录下的内容列表。输出的信息从左到右依次包括文件名,文件类型、权限模式、硬连接数、所有者、组、文件大小和文件的最后修改时间等;

-m:用“,”号区隔每个文件和目录的名称;

-n:以用户识别码和群组识别码替代其名称;

-r:以文件名反序排列并输出目录内容列表;

-s:显示文件和目录的大小,以区块为单位;

-t:用文件和目录的更改时间排序;

-L:如果遇到性质为符号链接的文件或目录,直接列出该链接所指向的原始文件或目录;

-R:递归处理,将指定目录下的所有文件及子目录一并处理;

--full-time:列出完整的日期与时间;

--color[=WHEN]:使用不同的颜色高亮显示不同类型的。