1e41f4b71Sopenharmony_ci# ls
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci## 命令功能
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_cils命令用来显示当前目录的内容。
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci## 命令格式
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_cils [_-ACHLSZacdfhiklmnopqrstux1_] [_--color_[_=auto_]] [_directory..._]
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
14e41f4b71Sopenharmony_ci>  系统启动过程中已经通过 alias 为 ls=toybox ls --color=auto 、ll = ls -alF 、 la=ls -A 和 l=ls -CF 赋能,使这几个命令的初始行为就和linux相同(详细效果见输出说明)。所以若要查看help列表,请输入'toybox ls --help'。
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci## 参数说明
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci**表1** 展示功能参数说明
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci| 参数   | 参数说明                                                     | 取值范围                      |
22e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ----------------------------- |
23e41f4b71Sopenharmony_ci| --help | 查看ls命令支持的参数列表,使用方式。                         | N/A                           |
24e41f4b71Sopenharmony_ci| -a     | 显示所有文件包括.hidden隐藏类型的文件。                      | N/A                           |
25e41f4b71Sopenharmony_ci| -b     | 转义非图形字符。                                             | N/A                           |
26e41f4b71Sopenharmony_ci| -c     | 使用ctime作为文件的时间戳,必须和-l参数一块使用。            | N/A                           |
27e41f4b71Sopenharmony_ci| -d     | 只显示path名称不显示path所包含的内容。                       | N/A                           |
28e41f4b71Sopenharmony_ci| -i     | 显示文件的节点号。                                           | N/A                           |
29e41f4b71Sopenharmony_ci| -p     | 在path名称后放一个"/"。                                      | N/A                           |
30e41f4b71Sopenharmony_ci| -q     | 显示不可打印字符比如'?'。                                    | N/A                           |
31e41f4b71Sopenharmony_ci| -s     | 统计目录和其成员所占用的内存大小,单位为1024字节。           | N/A                           |
32e41f4b71Sopenharmony_ci| -u     | 以文件的最后访问时间为时间戳,配合 -l 一起使用。   | N/A                           |
33e41f4b71Sopenharmony_ci| -A     | 列出所有文件除了.和..                                        | N/A                           |
34e41f4b71Sopenharmony_ci| -H     | 跟随命令行符号链接。                                         | N/A                           |
35e41f4b71Sopenharmony_ci| -L     | 跟随符号链接。                                               | N/A                           |
36e41f4b71Sopenharmony_ci| -Z     | 安全上下文。                                                 | N/A                           |
37e41f4b71Sopenharmony_ci| path   | path为空时,显示当前目录的内容。<br/>path为无效文件名时,显示失败,提示:<br/>ls&nbsp;error:&nbsp;No&nbsp;such&nbsp;directory。<br/>path为有效目录路径时,会显示对应目录下的内容。 | 1.为空。<br/>2.有效的目录路径 |
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci**表2** 输出格式参数说明
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci| 参数    | 参数说明                                |
42e41f4b71Sopenharmony_ci| ------- | --------------------------------------- |
43e41f4b71Sopenharmony_ci| -1      | 每行列出一个文件。                      |
44e41f4b71Sopenharmony_ci| -c      | 列,垂直排序。                          |
45e41f4b71Sopenharmony_ci| -g      | 类似于&nbsp;-l&nbsp;但没有所有者。      |
46e41f4b71Sopenharmony_ci| -h      | 统计path目录下文件的总大小,单位为KiB。 |
47e41f4b71Sopenharmony_ci| -l      | 详细的显示path目录下文件的信息。        |
48e41f4b71Sopenharmony_ci| -m      | 文件之间添加逗号。                      |
49e41f4b71Sopenharmony_ci| -n      | 类似&nbsp;-l&nbsp;数字格式显示uid/gid。 |
50e41f4b71Sopenharmony_ci| -o      | 类似&nbsp;-l&nbsp;但显示列表不包括组。  |
51e41f4b71Sopenharmony_ci| -x      | 列,水平排序。                          |
52e41f4b71Sopenharmony_ci| -ll     | 文件的时间属性显示纳秒。                |
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci**表3** 排序参数说明(默认为按首字母排序)
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci| 参数 | 参数说明                                   |
57e41f4b71Sopenharmony_ci| ---- | ------------------------------------------ |
58e41f4b71Sopenharmony_ci| -f   | 不排序。                                   |
59e41f4b71Sopenharmony_ci| -r   | 按首字母反向排序。                         |
60e41f4b71Sopenharmony_ci| -t   | 按文件的最后修改时间排序,最近时间为排头。 |
61e41f4b71Sopenharmony_ci| -S   | 按文件大小来排序,大文件为排头。           |
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci**表4** 彩色打印
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci| 参数 | 默认配置                                   |
66e41f4b71Sopenharmony_ci| ---- | ------------------------------------------ |
67e41f4b71Sopenharmony_ci| --color  | device=yellow symlink=turquoise/red dir=blue socket=purple files: exe=green suid=red suidfile=redback stickydir=greenback=auto means detect if output is a tty. |
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci## 使用指南
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci> **须知:**
74e41f4b71Sopenharmony_ci> fatfs的文件节点信息继承其父节点,父节点号为0。故在hi3516dv300开发板上ls -i显示的文件节点号全为0。
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci## 特殊说明
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_cils中参数shell端暂不支持。切换mksh版本可全支持,方法:cd bin; ./mksh。
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci## 使用实例
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci举例:
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci- ls
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci- ll
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci
89e41f4b71Sopenharmony_ci## 输出说明
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ci**示例1** ls命令查看当前路径下的内容
92e41f4b71Sopenharmony_ci
93e41f4b71Sopenharmony_ci```
94e41f4b71Sopenharmony_ciOHOS:/$ ls
95e41f4b71Sopenharmony_cibin  etc  nfs   sdcard   system    usr
96e41f4b71Sopenharmony_cidev  lib  proc  storage  userdata  vendor
97e41f4b71Sopenharmony_ci```
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci**示例2** ll命令查看当前路径下的内容
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci```
102e41f4b71Sopenharmony_ciOHOS:/$ ll
103e41f4b71Sopenharmony_citotal 20
104e41f4b71Sopenharmony_cidrwxrwxrwx 1 0 0 2048 2021-11-21 17:52 bin/
105e41f4b71Sopenharmony_cidrwxr-xr-x 0 0 0    0 1970-01-01 00:00 dev/
106e41f4b71Sopenharmony_cidrwxrwxrwx 1 0 0 2048 2021-11-21 17:52 etc/
107e41f4b71Sopenharmony_cidrwxrwxrwx 1 0 0 2048 2021-11-21 17:52 lib/
108e41f4b71Sopenharmony_cidrwxrwxrwx 0 0 0 4096 2021-10-25 02:17 nfs/
109e41f4b71Sopenharmony_cidr-xr-xr-x 0 0 0    0 1970-01-01 00:00 proc/
110e41f4b71Sopenharmony_cidrwxrwxrwx 1 0 0 4096 1979-12-31 00:00 sdcard/
111e41f4b71Sopenharmony_cidrwxrwxrwx 1 0 0 2048 2021-11-21 17:52 storage/
112e41f4b71Sopenharmony_cidrwxrwxrwx 1 0 0 2048 2021-11-21 17:52 system/
113e41f4b71Sopenharmony_cidrwxrwxrwx 1 0 0 2048 2021-11-21 17:52 userdata/
114e41f4b71Sopenharmony_cidrwxrwxrwx 1 0 0 2048 2021-11-21 17:52 usr/
115e41f4b71Sopenharmony_cidrwxrwxrwx 1 0 0 2048 2021-11-21 17:52 vendor/
116e41f4b71Sopenharmony_ci```