SysIII/usr/src/man/man1/ls.1

Compare this file to the similar file:
Show the results in this format:

.TH LS 1
.SH NAME
ls \- list contents of directories
.SH SYNOPSIS
.B ls
[
.B \-logtasdrucif
] names
.SH DESCRIPTION
For each directory named,
.I ls\^
lists the contents of that directory;
for each file named,
.I 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.
There are several options:
.TP
.B \-l
List in long format, giving mode, number of links, owner,
group, size in bytes, and time of last modification
for each file
(see below).
If the file is a special file, the size field will contain
the major and minor device numbers, rather than a size.
.TP
.B \-o
The same as
.BR \-l ,
except that the group is not printed.
.TP
.B \-g
The same as
.BR \-l ,
except that the owner is not printed.
.TP
.B \-t
Sort by time of last modification (latest first) instead of
by name.
.TP
.B \-a
List all entries;
in the absence of this option, entries whose names begin with a
period
.RB (\^ \&. \^)
are
.I not\^
listed.
.TP
.B \-s
Give size in blocks (including indirect blocks) for each entry.
.TP
.B \-d
If argument is a directory, list only its name;
often used with
.B \-l
to get the status of a directory.
.TP
.B \-r
Reverse the order of sort to get reverse alphabetic
or oldest first, as appropriate.
.TP
.B \-u
Use time of last access instead of last
modification for sorting
(with the
.B \-t
option)
and/or printing
(with the
.B \-l
option).
.TP
.B \-c
Use time of last modification of the inode
(mode, etc.)
instead of last modification of the file for sorting
.RB ( \-t )
and/or printing
.RB ( \-l ).
.TP
.B \-i
For each file, print the i-number in the first column
of the report.
.TP
.B \-f
Force each argument to be interpreted as a directory
and list the name found in each slot.
This option turns off
.BR \-l ,
.BR \-t ,
.BR \-s ,
and
.BR \-r ,
and
turns on
.BR \-a ;
the order is the order in which entries
appear in the directory.
.PP
The mode printed under the
.B \-l
option consists of 11 characters
that are interpreted
as follows:
.RS
.sp \n(PDu
The first character is:
.sp \n(PDu
.RS
.PD 0
.TP 4
.B d
if the entry is a directory;
.TP
.B b
if the entry is a block special file;
.TP
.B c
if the entry is a character special file;
.TP
.B p
if the entry is a fifo (a.k.a. ``named pipe'') special file;
.TP
.B \-
if the entry is an ordinary file.
.RE
.PD
.sp \n(PDu
The next 9 characters are interpreted
as three sets of three bits each.
The first set refers to the owner's permissions;
the next to permissions of others in the user-group of the file;
and the last to all others.
Within each set, the three characters indicate
permission to read, to write, and to
execute the file as a program, respectively.
For a directory, ``execute'' permission is interpreted
to mean permission to search the directory
for a specified file.
.sp \n(PDu
The permissions are indicated as follows:
.sp \n(PDu
.RS
.PD 0
.TP 4
.B r
if the file is readable;
.TP
.B w
if the file is writable;
.TP
.B x
if the file is executable;
.TP
.B \-
if the indicated permission is
.I not\^
granted.
.RE
.PD
.sp \n(PDu
The group-execute permission character is given
as
.B s
if the file has set-group-\s-1ID\s+1 mode;
likewise, the user-execute permission character is given
as
.B s
if the file has set-user-\s-1ID\s+1 mode.
The last character of the mode (normally
.B x
or
.BR \- )
is
.B t
if the 1000 (octal) bit of the mode is on;
see
.IR chmod (1)
for the meaning of this mode.
The indications of set-\s-1ID\s+1 and 1000 bit of the mode
are capitalized if the corresponding execute permission is
.I not\^
set.
.RE
.PP
When the sizes of the files in a directory
are listed, a total count of blocks,
including indirect blocks, is printed.
.SH FILES
.PD 0
.TP 8m
/etc/passwd
to get user
.SM ID\*Ss
for
.B "ls \-l"
and
.BR "ls \-o" .
.TP
/etc/group
to get group
.SM ID\*Ss
for
.B "ls \-l"
and
.BR "ls \-g" .
.PD
.SH SEE ALSO
chmod(1),
find(1).