ls

Command Function

This command is used to display the content of a specified directory.

Syntax

ls [path]

Parameters

Table 1 Parameter description

Parameter

Description

Value Range

path

If path is left blank, the content of the current directory is displayed.

If the path value is an invalid file name, the following failure message is displayed:

ls error: No such directory

If the path value is a valid directory, the content of this directory is displayed.

Left blank

A valid directory

Usage

  • This command can be used to display the content of the current directory.
  • This command can also display the size of a file.
  • The ls command with the proc directory passed cannot calculate the file size, and 0 is displayed in the command output.

Example

Run ls.

Output

Figure 1 Displaying content of the current directory