1# ls 2 3 4## Command Function 5 6This command is used to display the content of a directory. 7 8 9## Syntax 10 11ls [_-ACHLSZacdfhiklmnopqrstux1_] [_--color_[_=auto_]] [_directory..._] 12 13> **NOTE**<br> 14> During the system boot process, **ls=toybox ls --color=auto**, **ll = ls -alF**, **la=ls -A**, and **l=ls -CF** commands have been enabled using **alias** so that the initial actions of these commands are the same as those on Linux. For details, see **Output**. To view help information, run **toybox ls --help**. 15 16 17## Parameters 18 19**Table 1** Command parameter description 20 21| Parameter | Description | Value Range | 22| ------ | ------------------------------------------------------------ | ----------------------------- | 23| --help | Displays parameters supported by the **ls** command and their usage. | N/A | 24| -a | Displays all files, including hidden files. | N/A | 25| -b | Escapes non-graphical characters. | N/A | 26| -c | Uses **ctime** as the file timestamp. This parameter must be used together with **-l**. | N/A | 27| -d | Displays only the directory, rather than listing the content of the directory. | N/A | 28| -i | Displays the node ID of a file. | N/A | 29| -p | Adds a slash (/) after the directory. | N/A | 30| -q | Displays non-printable characters, such as "?". | N/A | 31| -s | Provides information about the memory occupied by the directory and its members, in 1024 bytes. | N/A | 32| -u | Uses the last access time of the file as the timestamp. This option is used together with **-l**. | N/A | 33| -A | Lists all files except implied . and .. | N/A | 34| -H | Follows symbolic links listed in the command line. | N/A | 35| -L | Follows symbolic links. | N/A | 36| -Z | Displays security context. | N/A | 37| path | Specifies the path of the target directory.<br/>If **path** is left blank, the content of the current directory is displayed.<br>If **path** is an invalid directory, "ls error: No such directory." is displayed.<br><br>If **path** is a valid directory, the content of the specified directory is displayed. | Left blank<br>A valid directory| 38 39**Table 2** Output format parameters 40 41| Parameter | Description | 42| ------- | --------------------------------------- | 43| -1 | Lists one file per line. | 44| -c | Lists entries by column. | 45| -g | Like **-l**, but do not list the owner. | 46| -h | Displays the total size of files in the directory, in KiB.| 47| -l | Displays detailed information about files in the directory. | 48| -m | Fills width with a list of entries separated by a comma. | 49| -n | Like **-l**, but lists numeric user and group IDs.| 50| -o | Like **-l**, but do not list group information. | 51| -x | Lists entries by line, instead of by column. | 52| -ll | Lists the file time attribute as ns. | 53 54**Table 3** Parameters for sorting (by the initial letter by default) 55 56| Parameter| Description | 57| ---- | ------------------------------------------ | 58| -f | Do not sort. | 59| -r | Sorts in reverse order. | 60| -t | Sorts by time, newest first.| 61| -S | Sorts by file size, largest first. | 62 63**Table 4** Color printing 64 65| Parameter| Default Configuration | 66| ---- | ------------------------------------------ | 67| --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. | 68 69## Usage Guidelines 70 71The file node information of the FAT file system inherits from its parent node. The parent node ID is **0**. Therefore, if you run the **ls -i** command on the Hi3516D V300 development board, the file node IDs displayed are all **0**. 72 73 74## Note 75 76The shell does not support **ls** parameters. mksh supports them. To switch to mksh, run **cd bin** and **./mksh**. 77 78## Example 79 80Run the following commands: 81 82- ls 83 84- ll 85 86 87## Output 88 89Example 1: **ls** command output 90 91``` 92OHOS:/$ ls 93bin etc nfs sdcard system usr 94dev lib proc storage userdata vendor 95``` 96 97Example 2: **ll** command output 98 99``` 100OHOS:/$ ll 101total 20 102drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 bin/ 103drwxr-xr-x 0 0 0 0 1970-01-01 00:00 dev/ 104drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 etc/ 105drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 lib/ 106drwxrwxrwx 0 0 0 4096 2021-10-25 02:17 nfs/ 107dr-xr-xr-x 0 0 0 0 1970-01-01 00:00 proc/ 108drwxrwxrwx 1 0 0 4096 1979-12-31 00:00 sdcard/ 109drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 storage/ 110drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 system/ 111drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 userdata/ 112drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 usr/ 113drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 vendor/ 114``` 115