Modular Computers the manual GitHub

ls

ls: list directory contents.

Synopsis

ls [-1aChlFS] [–color[=\fIwhen\fP]] [path…]

Description

ls lists what is in each directory named, and names each file named (a file lists itself). With no path, it lists the current directory. Files named on the command line come first, then each directory; with more than one path, each directory’s list is headed by its name and a colon. Names are listed in the order the directory gives them (sorted).

Names starting with a dot are left out unless -a is given.

When standard output is a terminal, names are laid out in columns, filled down then across, as many as fit the terminal’s width; directories show in bold blue and symbolic links in bold cyan. Into a pipe or a file, names go one a line, without colors (unless –color=always says otherwise).

Options

Options may be combined (-la) and may come anywhere among the paths.

-1
One name a line.
-a
Include names starting with a dot.
-C
Columns, even when output is not a terminal (then 80 columns wide).
-l
Long format: a type letter (d directory, l symbolic link, c device, p pipe, - file), the size in bytes, and the name; a link’s target follows ->. A link named on the command line is shown as itself, not as what it points to.
-h
With -l, sizes for people to read: bytes under 1024, else in K, M, G or T (each 1024 of the last), with a tenth under 10 of a unit (1.5K), whole above (12K), rounded up, as GNU ls shows them.
–color[=when]
When to color names: auto (on a terminal only, as with no –color), always (also given by –color alone), or never. GNU’s other words for each (tty, yes, none…) are taken too.
-F
Append / to directories and @ to symbolic links.
-S
Sort by size, largest first (names in order where sizes are the same).

Exit status

0 on success; 2 on a bad option or –color argument, or if any path could not be read.

Notes

Colors are on by default on a terminal, as if –color=auto were given (GNU ls colors only when asked; distributions’ shell aliases ask). There are no owners, permissions or times to show, so -l gives only the type, the size and the name. A symbolic link to nothing is listed as the link.

See also

tree(1), find(1), du(1), df(1), ln(1)