don't need pathnames.h any more
[unix-history] / usr / src / bin / ls / ls.1
CommitLineData
a10206cc
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
4e9923b0 5.\" @(#)ls.1 6.9 (Berkeley) %G%
a10206cc 6.\"
4a3d96b7 7.TH LS 1 ""
a10206cc
KM
8.UC
9.SH NAME
10ls \- list contents of directory
11.SH SYNOPSIS
12.B ls
13[
4e9923b0 14.B \-acdgilqrstu1ACLFR
a10206cc
KM
15] name ...
16.br
a10206cc
KM
17.SH DESCRIPTION
18For each directory argument,
19.I ls
20lists the contents of the directory;
21for each file argument,
22.I ls
23repeats its name and any other information requested.
30149789 24By default, the output is sorted alphabetically.
a10206cc
KM
25When no argument is given, the current directory is listed.
26When several arguments are given,
27the arguments are first sorted appropriately,
30149789 28but file arguments are processed
a10206cc
KM
29before directories and their contents.
30.PP
30149789 31There are a large number of options:
a10206cc 32.TP
30149789 33.B \-l
a10206cc
KM
34List in long format, giving mode, number of links, owner,
35size in bytes, and time of last modification
36for each file.
37(See below.)
38If the file is a special file the size field will instead contain
39the major and minor device numbers.
30149789
KM
40If the file is a symbolic link the pathname of
41the linked-to file is printed preceded by ``\->''.
42.TP
43.B \-g
44Include the group ownership of the file in a long output.
a10206cc 45.TP
30149789 46.B \-t
a10206cc 47Sort by time modified (latest first) instead of
30149789 48by name.
a10206cc 49.TP
30149789
KM
50.B \-a
51List all entries; in the absence of this option, entries whose
52names begin with a period
53.RB ( . )
54are
55.I not
56listed.
a10206cc 57.TP
0a413117
KB
58.B \-A
59List all entries except for ``.'' and ``..''. Always set for the
60super-user.
61.TP
30149789
KM
62.B \-s
63Give size in kilobytes of each file.
a10206cc 64.TP
30149789
KM
65.B \-d
66If argument is a directory, list only its name;
67often used with \fB\-l\fR to get the status of a directory.
68.TP
69.B \-L
70If argument is a symbolic link, list the file or directory the link references
71rather than the link itself.
a10206cc 72.TP
30149789 73.B \-r
ccc80378
MK
74Reverse the order of sort to get reverse alphabetic
75or oldest first as appropriate.
a10206cc 76.TP
30149789 77.B \-u
a10206cc
KM
78Use time of last access instead of last
79modification for sorting
30149789
KM
80(with the \fB\-t\fP option)
81and/or printing (with the \fB\-l\fP option).
a10206cc 82.TP
30149789 83.B \-c
aa97bb7c 84Use time when file status was last changed for sorting or printing.
a10206cc 85.TP
30149789
KM
86.B \-i
87For each file, print the i-number in the first column of the report.
a10206cc 88.TP
30149789
KM
89.B \-F
90cause directories to be marked with a trailing `/',
91sockets with a trailing `=',
92symbolic links with a trailing `@', and executable
93files with a trailing `*'.
a10206cc 94.TP
30149789
KM
95.B \-R
96recursively list subdirectories encountered.
a10206cc 97.TP
30149789
KM
98.B \-1
99force one entry per line output format; this is the default when
100output is not to a terminal.
a10206cc 101.TP
30149789
KM
102.B \-C
103force multi-column output; this is the default when output is to a terminal.
a10206cc 104.TP
30149789 105.B \-q
a10206cc 106force printing of non-graphic characters in file names as
30149789 107the character `?'; this is the default when output is to a terminal.
a10206cc
KM
108.PP
109The mode printed under the
110.B \-l
111option contains 11 characters
112which are interpreted
113as follows:
114the first character is
115.TP 3
30149789 116.B d
a10206cc
KM
117if the entry is a directory;
118.br
119.ns
120.TP 3
30149789 121.B b
a10206cc
KM
122if the entry is a block-type special file;
123.br
124.ns
125.TP 3
30149789 126.B c
a10206cc
KM
127if the entry is a character-type special file;
128.br
129.ns
130.TP 3
30149789
KM
131.B l
132if the entry is a symbolic link;
133.br
134.ns
135.TP
136.B s
137if the entry is a socket, or
a10206cc
KM
138.br
139.ns
140.TP 3
141.B \-
142if the entry is a plain file.
143.PP
144The next 9 characters are interpreted
145as three sets of three bits each.
146The first set refers to owner permissions;
adbdb3c0 147the next refers to permissions to others in the same user-group;
a10206cc
KM
148and the last to all others.
149Within each set the three characters indicate
150permission respectively to read, to write, or to
151execute the file as a program.
152For a directory, `execute' permission is interpreted
30149789 153to mean permission to search the directory.
a10206cc
KM
154The permissions are indicated as follows:
155.TP 3
156.B r
157if the file is readable;
158.br
159.ns
160.TP 3
161.B w
162if the file is writable;
163.br
164.ns
165.TP 3
166.B x
167if the file is executable;
168.br
169.ns
170.TP 3
171.B \-
172if the indicated permission is not granted.
173.PP
303dbd7d
KB
174The group-execute permission character is given as \fBs\fP if the file has
175the set-group-id bit set; likewise the user-execute permission character is
176given as \fBs\fP if the file has the set-user-id bit set. These are given
177as \fBS\fP (capitalized) if the corresponding execute permission is NOT
178set.
a10206cc
KM
179.PP
180The last character of the mode (normally `x' or `\-') is
181.B t
182if the 1000 bit of the mode is on.
183See
184.IR chmod (1)
303dbd7d
KB
185for the meaning of this mode. This is given as \fBT\fP (capitalized) if the
186corresponding execute permission is NOT set.
a10206cc
KM
187.PP
188When the sizes of the files in a directory
189are listed, a total count of blocks,
190including indirect blocks is printed.
191.SH FILES
30149789 192/etc/passwd to get user id's for
a10206cc
KM
193`ls \-l'.
194.br
30149789 195/etc/group to get group id's for
a10206cc
KM
196`ls \-g'.
197.SH BUGS
198Newline and tab are considered printing characters in file names.
199.PP
200The output device is assumed to be 80 columns wide.
201.PP
202The option setting based on whether the output is a teletype is
203undesirable as ``ls\ \-s'' is much different than ``ls\ \-s\ |\ lpr''.
204On the other hand, not doing this setting would make old shell scripts
205which used
206.I ls
207almost certain losers.