4.3BSD beta release manual page
[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.\"
4a3d96b7 5.\" @(#)ls.1 6.1 (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[
30149789 14.B \-acdfgilqrstu1ACLFR
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
30149789
KM
58.B \-s
59Give size in kilobytes of each file.
a10206cc 60.TP
30149789
KM
61.B \-d
62If argument is a directory, list only its name;
63often used with \fB\-l\fR to get the status of a directory.
64.TP
65.B \-L
66If argument is a symbolic link, list the file or directory the link references
67rather than the link itself.
a10206cc 68.TP
30149789 69.B \-r
a10206cc
KM
70Reverse the order of sort to get reverse alphabetic
71or oldest first as appropriate.
72.TP
30149789 73.B \-u
a10206cc
KM
74Use time of last access instead of last
75modification for sorting
30149789
KM
76(with the \fB\-t\fP option)
77and/or printing (with the \fB\-l\fP option).
a10206cc 78.TP
30149789 79.B \-c
a10206cc
KM
80Use time of file creation for sorting or printing.
81.TP
30149789
KM
82.B \-i
83For each file, print the i-number in the first column of the report.
a10206cc 84.TP
30149789 85.B \-f
a10206cc
KM
86Force each argument to be interpreted as a directory
87and list the name found in each slot.
88This option turns off
89.B "\-l, \-t, \-s,"
90and
91.B \-r,
92and
93turns on
94.B \-a;
95the order is the order in which entries
96appear in the directory.
97.TP
30149789
KM
98.B \-F
99cause directories to be marked with a trailing `/',
100sockets with a trailing `=',
101symbolic links with a trailing `@', and executable
102files with a trailing `*'.
a10206cc 103.TP
30149789
KM
104.B \-R
105recursively list subdirectories encountered.
a10206cc 106.TP
30149789
KM
107.B \-1
108force one entry per line output format; this is the default when
109output is not to a terminal.
a10206cc 110.TP
30149789
KM
111.B \-C
112force multi-column output; this is the default when output is to a terminal.
a10206cc 113.TP
30149789 114.B \-q
a10206cc 115force printing of non-graphic characters in file names as
30149789 116the character `?'; this is the default when output is to a terminal.
a10206cc
KM
117.PP
118The mode printed under the
119.B \-l
120option contains 11 characters
121which are interpreted
122as follows:
123the first character is
124.TP 3
30149789 125.B d
a10206cc
KM
126if the entry is a directory;
127.br
128.ns
129.TP 3
30149789 130.B b
a10206cc
KM
131if the entry is a block-type special file;
132.br
133.ns
134.TP 3
30149789 135.B c
a10206cc
KM
136if the entry is a character-type special file;
137.br
138.ns
139.TP 3
30149789
KM
140.B l
141if the entry is a symbolic link;
142.br
143.ns
144.TP
145.B s
146if the entry is a socket, or
a10206cc
KM
147.br
148.ns
149.TP 3
150.B \-
151if the entry is a plain file.
152.PP
153The next 9 characters are interpreted
154as three sets of three bits each.
155The first set refers to owner permissions;
156the next to permissions to others in the same user-group;
157and the last to all others.
158Within each set the three characters indicate
159permission respectively to read, to write, or to
160execute the file as a program.
161For a directory, `execute' permission is interpreted
30149789 162to mean permission to search the directory.
a10206cc
KM
163The permissions are indicated as follows:
164.TP 3
165.B r
166if the file is readable;
167.br
168.ns
169.TP 3
170.B w
171if the file is writable;
172.br
173.ns
174.TP 3
175.B x
176if the file is executable;
177.br
178.ns
179.TP 3
180.B \-
181if the indicated permission is not granted.
182.PP
183The group-execute permission character is given
184as
185.B s
30149789 186if the file has the set-group-id bit set;
a10206cc
KM
187likewise the user-execute permission character is given
188as
189.B s
30149789 190if the file has the set-user-id bit set.
a10206cc
KM
191.PP
192The last character of the mode (normally `x' or `\-') is
193.B t
194if the 1000 bit of the mode is on.
195See
196.IR chmod (1)
197for the meaning of this mode.
198.PP
199When the sizes of the files in a directory
200are listed, a total count of blocks,
201including indirect blocks is printed.
202.SH FILES
30149789 203/etc/passwd to get user id's for
a10206cc
KM
204`ls \-l'.
205.br
30149789 206/etc/group to get group id's for
a10206cc
KM
207`ls \-g'.
208.SH BUGS
209Newline and tab are considered printing characters in file names.
210.PP
211The output device is assumed to be 80 columns wide.
212.PP
213The option setting based on whether the output is a teletype is
214undesirable as ``ls\ \-s'' is much different than ``ls\ \-s\ |\ lpr''.
215On the other hand, not doing this setting would make old shell scripts
216which used
217.I ls
218almost certain losers.