ls
Command Function
This command is used to display the content of a specified directory.
Syntax
ls [-ACHLSZacdfhiklmnopqrstux1] [--color[=auto]] [directory...]
NOTE:
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 the output description. To view help information, run toybox ls --help.
Parameters
Table 1 Command parameter description
Parameter
|
Description
|
Value Range
|
--help
|
Displays parameters supported by the ls command and their usage.
|
N/A
|
-a
|
Displays all files, including .hidden files.
|
N/A
|
-b
|
Escapes non-graphical characters.
|
N/A
|
-c
|
Uses ctime as the file timestamp. This parameter must be used together with -l.
|
N/A
|
-d
|
Displays only the directory, rather than listing the content of the directory.
|
N/A
|
-i
|
Displays the node ID of a file.
|
N/A
|
-p
|
Adds a slash (/) after the directory.
|
N/A
|
-q
|
Displays non-printable characters, such as "?".
|
N/A
|
-s
|
Provides information about the memory occupied by the directory and its members, in 1024 bytes.
|
N/A
|
-u
|
Uses the last access time of the file as the timestamp. This option is used together with -l.
|
N/A
|
-A
|
Lists all files except implied . and ..
|
N/A
|
-H
|
Follows symbolic links listed in the command line.
|
N/A
|
-L
|
Follows symbolic links.
|
N/A
|
-Z
|
Displays security context.
|
N/A
|
path
|
If path is left blank, the content of the current directory is displayed.
If path is an invalid file name, the following failure message is displayed:
ls error: No such directory
If path is a valid directory, the content of that directory is displayed.
|
Left blank or a valid directory
|
Table 2 Output parameters
Parameter
|
Description
|
Value Range
|
-1
|
Lists one file per line.
|
N/A
|
-c
|
Lists entries by column.
|
N/A
|
-g
|
Like -l, but do not list owner.
|
N/A
|
-h
|
Displays the total size of files in the directory, in KiB.
|
N/A
|
-l
|
Displays detailed information about files in the directory.
|
N/A
|
-m
|
Fills width with a list of entries separated by a comma.
|
N/A
|
-n
|
Like -l, but lists numeric user and group IDs.
|
N/A
|
-o
|
Like -l, but do not list group information.
|
N/A
|
-x
|
Lists entries by line, instead of by column.
|
N/A
|
-ll
|
Lists the file time attribute as ns.
|
N/A
|
--color
|
Colorizes the output.
|
Default value: 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.
|
Table 3 Sorting parameters (sorted by the initial letter by default)
Parameter
|
Description
|
Value Range
|
-f
|
Do not sort.
|
N/A
|
-r
|
Reverse order while sorting.
|
N/A
|
-t
|
Sort by time, newest first.
|
N/A
|
-S
|
Sort by file size, largest first.
|
N/A
|
Usage
None
NOTICE:
The 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.
Example
Run the following commands:
Output
Example 1: ls command output
OHOS:/$ ls
bin etc nfs sdcard system usr
dev lib proc storage userdata vendor
Example 2: ll command output
OHOS:/$ ll
total 20
drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 bin/
drwxr-xr-x 0 0 0 0 1970-01-01 00:00 dev/
drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 etc/
drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 lib/
drwxrwxrwx 0 0 0 4096 2021-10-25 02:17 nfs/
dr-xr-xr-x 0 0 0 0 1970-01-01 00:00 proc/
drwxrwxrwx 1 0 0 4096 1979-12-31 00:00 sdcard/
drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 storage/
drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 system/
drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 userdata/
drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 usr/
drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 vendor/