LS(1B)

NAME
ls - (BSD) list contents of directory

SYNOPSIS
/usr/local/heirloom/usr/ucb/ls [-aAcCdfFgHilLqrRstu1hSUX] [file ...]

DESCRIPTION
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:

-a  List all entries; usually files that begin with a `.' are suppressed.

-A  List all entries except `.' and `..'. This is default if ls is invoked by the super-user.

-c  Use time of last modification to inode (mode, etc.) instead of last modification to file for sorting (-t) or printing (-l).

-C  Output is printed in multiple columns, sorted down the columns. This format is selected by default if standard output refers to a terminal.

-d  If argument is a directory, list only its name, not its contents (mostly used with -l to get status on directory).

-f  Force each argument to be interpreted as a directory and list the name found in each slot. This option turns off -l, -t, -s, and -r, and turns on -a; the order is the order in which entries appear in the directory.

-F  Indicates the file type as a letter appended to each pathname:

    / | directory
    * | executable file
    @ | symbolic link
    | | named pipe
     | socket
    > | door

-g  If combined with -l, the group ID is added to the output.

-i  Print i-number in first column of the report for each file listed.

-l  List in long format, giving mode, number of links, owner, size in bytes, and time of last modification for each file. (See below.) If the file is a special file the size field will instead contain the major and minor device numbers. Symbolic links specified as arguments are not followed with this option unless the -H or -L option is also present.

-L  Follow symbolic links in arguments.

-q  Non-printable characters are printed as question marks `?'. This is the default if standard output refers to a terminal.

-r  Reverse the order of sort to get reverse alphabetic or oldest first as appropriate.

-R  Lists subdirectories recursively.

-s  Give size in blocks, including indirect blocks, for each entry.

-t  Sort by time modified (latest first) instead of by name, as is normal.

-u  Use time of last access instead of last modification for sorting (-t) or printing (-l).

-1  Print one filename per output line. This is the default if standard output does not refer to a terminal.

The following option was introduced with POSIX.1-2001:

-H  Follow symbolic links given as arguments.

The following options are available as extensions:

-h  Print file sizes in human-readable powers of 1024, i.e. `K' for kilobyte, `M' for megabyte, `G' for gigabyte, `T' for terabyte, `P' for petabyte, and `E' for exabyte.

-S  Sort by file size.

-U  Do not sort at all.

-X  Sort by file name extension, i.e. by the component of the file name following the last dot.

The mode printed under the -l option 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 door;
- | 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;
S | if the set-group-ID bit is set on the file but it is not executable.

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 door;
magenta | if the file is a XENIX 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).

FILES

/etc/passwd
    to get user IDs.

/etc/group
    to get group IDs.

ENVIRONMENT VARIABLES

COLUMNS
    Overrides the auto-detected terminal width.

LANG, LC_ALL
    See locale(7).

LC_COLLATE
    Affects the order of printed items when sorting by name.

LC_CTYPE
    Determines whether a character is printable.

LC_TIME
    Sets the format of time strings printed with the -l option.

TERM
    Used to determine the terminal type.

SEE ALSO
chmod(1), locale(7)