LS(1) COMMAND REFERENCE LS(1)
NAME
ls, lf, lg, ll, lr, lx - list contents of directory
SYNOPSIS
ls [ -1 ] [ -A ] [ -C ] [ -F ] [ -L ] [ -R ] [ -a ] [ -c ] [
-d ] [ -f ] [ -g ] [ -h ] [ -i ] [ -l ] [ -q ] [ -r ] [ -s ]
[ -t ] [ -u ] [ -x ] filename...
DESCRIPTION
For each argument that names a directory or symbolic link to
a directory (unless -l is specified), ls lists the contents
of the directory; for each file argument, ls repeats its
name and any other information requested. By default, the
output is sorted alphabetically. When no argument is given,
the current directory is listed. When several arguments are
given, the arguments are first sorted appropriately, but
file arguments are processed before directories and their
contents.
The commands lf, lg, ll, lr, and lx are links to ls which
set flags as follows:
lf -F
lg -l, -g
ll -l
lr -R
lx -x
The mode printed under the -l option contains 11 characters
which are interpreted as follows: the first character is
b if the entry is a block-type special file;
c if the entry is a character-type special file;
d if the entry is a directory;
D if the entry is a symbolic link that points to a
directory;
l if the entry is a symbolic link, or
s if the entry is a socket
- 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. The permissions are
Printed 10/17/86 1
LS(1) COMMAND REFERENCE LS(1)
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 the set-group-id bit set; likewise the user-execute
permission character is given as s if the file has the set-
user-id bit set.
The last character of the mode (normally `x' or `-') is t if
the 1000 bit of the mode is on. 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 is printed. If you find the size
using the -s option, this reflects the actual amount of disk
space a file consumes. In this case, a count of indirect
blocks is also printed. If you find the size using the -l
option, a count of indirect blocks is NOT included. The
size obtained with -l is not the actual number of bytes, but
an end of data location. Unless the file was created by
skipping around and writing, this is the actual number of
bytes consumed.
OPTIONS
-a List all entries; in the absence of this option, entries
whose names begin with a period ( . ) are not listed.
-A list all entries except '.' and '..'. This option is
always set for the super-user.
-c Use time of the last file status change for sorting or
printing. This time is the last time that the file's
data or the i-node was changed (meaning the last time
the data was changed or the file was linked to. See the
manual page for stat(2) for more information).
-C force multi-column output; this is the default when
output is to a terminal.
-d If argument is a directory, list only its name; often
used with -l to get the status of a 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 cause directories to be marked with a trailing `/',
Printed 10/17/86 2
LS(1) COMMAND REFERENCE LS(1)
symbolic links with a trailing `@', executable files
with a trailing `*', and sockets with a trailing '='.
All symbolic links to existing directories are marked
with a trailing `@/'. All symbolic links to existing
executable files are marked with a trailing `@*'. All
symbolic links to nonexistent files are marked with a
trailing `@?'.
-g Include the group ownership of the file in a long
output.
-h Follow only ``hard'' directory paths during recursion
(-R option). By default, symbolic links to directories
are traversed (except when -l is used without -L). This
option prevents these symbolic links from being
traversed.
-i For each file, print the i-number in the first column of
the report.
-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. If the file is a symbolic link the
pathname of the linked-to file is printed preceded by
``->''.
-L If argument is a symbolic link, list the file or
directory the link references rather than the link
itself.
-q force printing of non-graphic characters in file names
as the character `?'; this is the default when output is
to a terminal.
-r Reverse the order of sort to get reverse alphabetic or
oldest first as appropriate.
-R recursively list subdirectories encountered. (Note: In
order to avoid symbolic link loops, directories are only
traversed the first time they are encountered, whether
as a regular directory or as a symbolic link.)
-s Give size in kilobytes of each file.
-t Sort by time modified (latest first) instead of by name.
-u Use time of last access instead of last modification for
sorting (with the -t option) and/or printing (with the
-l option).
Printed 10/17/86 3
LS(1) COMMAND REFERENCE LS(1)
-x List only directories. If the -L option is also given,
symbolic links to directories will also be listed.
-1 force one entry per line output format; this is the
default when output is not to a terminal.
EXAMPLES
The following example lists all of the files in the
directory /bin.
ls /bin
FILES
/etc/passwd to get user id's for `ls -l'.
/etc/group to get group id's for `ls -g'.
RETURN VALUE
[NO_ERRS] Command completed without error.
[NP_ERR] An error occurred that was not a system
error. Execution terminated.
[P_WARN] A system error occurred. Execution continues.
See intro(2) for more information on system
errors.
CAVEATS
Newline and tab are considered printing characters in file
names.
The output device is assumed to be 80 columns wide.
The date printed in the long listing (-l option) will
contain the time of day if the file is up to six months old
or has a date up to 48 hours in the future. All other dates
will print with the year instead of the time.
The option setting based on whether the output is a teletype
is undesirable as ls -s is much different than ls -s | lpr .
On the other hand, not doing this setting would make old
shell scripts which used ls almost certain losers.
The commands lf(1), lg(1), ll(1), lr(1), and lx(1) are not
separate programs; they are links to ls. This means that
removing these commands will not free up a lot of disk
space. This also means that modifying ls requires re-linking
the commands.
Printed 10/17/86 4
LS(1) COMMAND REFERENCE LS(1)
SEE ALSO
cat(1), chmod(1), find(1), rm(1).
Printed 10/17/86 5
%%index%%
na:72,87;
sy:159,496;
de:655,1934;2733,1237;
op:3970,1333;5447,2340;7931,274;
ex:8205,164;
fi:8369,193;
rv:8562,415;
ca:8977,1052;
se:10173,176;
%%index%%000000000178