LS(1) | User Commands | LS(1) |
ls, lc - list contents of directory
ls [-abcCdfFgHilLmnopqrRstux1hSUX] [file ...]
lc [-abcCdfFgHilLmnopqrRstux1hSUX] [file ...]
For each directory argument, ls lists the contents of the directory; for each file argument, ls repeats its name and any other information requested. The output is sorted alphabetically by default. When no argument is given, the current directory is listed. When several arguments are given, the arguments are first sorted appropriately, but file arguments appear before directories and their contents. There are several options:
/ | directory |
* | executable file |
@ | symbolic link |
| | named pipe |
= | socket |
> | Solaris door |
The following option was introduced with POSIX.1-2001:
The following options are available as extensions:
The mode printed under the -l, -g, and -o options contains 10 characters which are interpreted as follows: the first character is
d | if the entry is a directory; |
b | if the entry is a block-type special file; |
c | if the entry is a character-type special file; |
p | if the entry is a named pipe; |
l | if the entry is a symbolic link; |
S | if the entry is a socket; |
s | if the entry is a XENIX semaphore; |
m | if the entry is a XENIX shared data (memory) file; |
D | if the entry is a Solaris door; |
n | if the entry is a HP-UX network special file; |
- | if the entry is a plain file. |
The next 9 characters are interpreted as three sets of three bits each. The first set refers to owner permissions; the next to permissions to others in the same user-group; and the last to all others. Within each set the three characters indicate permission respectively to read, to write, or to execute the file as a program. For a directory, `execute' permission is interpreted to mean permission to search the directory for a specified file. The permissions are indicated as follows:
r | if the file is readable; |
w | if the file is writable; |
x | if the file is executable; |
- | if the indicated permission is not granted. |
The group-execute permission character is given as
s | if the file has set-group-ID mode; |
l | if mandatory locking is enabled for the file (with /usr/5bin/ls and /usr/5bin/s42/ls); |
L | if mandatory locking is enabled for the file (with /usr/5bin/posix/ls and /usr/5bin/posix2001/ls). |
Likewise the user-execute permission character is given as
s | if the file has set-user-ID mode; |
S | if the set-user-ID bit is set on the file but it is not executable. |
The last character of the mode (normally `x' or `-') is
t | if the sticky bit of the mode is on; |
T | if the sticky bit is on but the file is not executable. |
See chmod(1) for the meaning of this mode.
When the sizes of the files in a directory are listed, a total count of blocks, including indirect blocks is printed.
If ls writes its output to a terminal that supports colors or boldface, file names printed are colorized according to their types:
blue/bold | if the file is a directory; |
yellow/bold | if the file is a special file; |
yellow | if the file is a named pipe; |
cyan | if the file is a symbolic link; |
magenta/bold | if the file is a socket or a Solaris door; |
magenta | if the file is a XENIX special file or a HP-UX network special file; |
green/bold | if the file is executable. |
For lc, colors are enabled even if the output is not written to a terminal. This is mainly useful if the output is filtered through a pager which handles colors, such as pg(1).
chmod(1), locale(7)
2/24/05 | Heirloom Toolchest |