“Linux常用命令”的版本间的差异
跳到导航
跳到搜索
(a) |
|||
第227行: | 第227行: | ||
==== kill常用参数示例 ==== | ==== kill常用参数示例 ==== | ||
=== find === | |||
=== sed === | |||
=== grep === | |||
=== free === | |||
=== sort === | |||
=== who === | |||
=== ifconfig === | |||
=== top === | |||
=== vi === |
2021年10月14日 (四) 12:19的版本
ls ——List
ls 介绍
List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified. 列出有关文件的信息(默认为当前目录)。如果没有指定-cftuvSUX或——Sort,则按字母顺序排序。
官方的说的很清楚,默认列出当前目录,所以可以列出其他目录或者路径下的文件信息或者目录信息。 比如:
$ls /etc/hosts
/etc/hosts
ls 参数格式
ls [OPTION]... [FILE]...
ls命令参数
-a 列出指定目录下的所有文件,包括隐藏文件
-c 使用最后一次更改文件状态以进行排序(-t)或长时间打印(-l)的时间
-h 与-l选项一起使用时,请使用单位后缀:Byte、Kilobyte、mete、gb、tb和Petabyte,以便使用以2为基数的大小将数字减少到3或更少
-l 长格式列表。(见下文)。如果输出到终端,则所有文件大小的总和将输出到长清单前面的一行中
-n 以数字形式显示用户和组id,而不是在长(-l)输出中转换为用户或组名。这个选项默认打开-l选项
-o 以长格式列出,但省略组id
-s 显示每个文件实际使用的文件系统块的数量,以512字节为单位,其中部分单元四舍五入为下一个整数值
-t 在按照字典顺序对操作数排序之前,先按修改的时间排序(最近修改的是first)
-u 使用最后一次访问的时间,而不是最后一次修改文件进行排序
ls 用法示例
[root@bogon ~]# ls
anaconda-ks.cfg test.txt
[root@bogon ~]# ls -a
. .. anaconda-ks.cfg .bash_logout .bash_profile .bashrc .cshrc .tcshrc test.txt
[root@bogon ~]# ls -l
总用量 8
-rw-------. 1 root root 1269 9月 3 20:01 anaconda-ks.cfg
-rw-r--r--. 1 root root 5 9月 10 10:46 test.txt
[root@bogon ~]# ls -lh
总用量 8.0K
-rw-------. 1 root root 1.3K 9月 3 20:01 anaconda-ks.cfg
-rw-r--r--. 1 root root 5 9月 10 10:46 test.txt
[root@bogon ~]# ls -ll
总用量 8
-rw-------. 1 root root 1269 9月 3 20:01 anaconda-ks.cfg
-rw-r--r--. 1 root root 5 9月 10 10:46 test.txt
[root@bogon ~]# ls -alh
总用量 28K
dr-xr-x---. 2 root root 130 9月 10 14:15 .
dr-xr-xr-x. 19 root root 253 9月 3 12:18 ..
-rw-------. 1 root root 1.3K 9月 3 20:01 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
-rw-r--r--. 1 root root 5 9月 10 10:46 test.txt
[root@bogon ~]# ls -o
总用量 8
-rw-------. 1 root 1269 9月 3 20:01 anaconda-ks.cfg
-rw-r--r--. 1 root 5 9月 10 10:46 test.txt
[root@bogon ~]# ls -oh
总用量 8.0K
-rw-------. 1 root 1.3K 9月 3 20:01 anaconda-ks.cfg
-rw-r--r--. 1 root 5 9月 10 10:46 test.txt