386BSD 0.1 development
[unix-history] / usr / src / bin / ls / ls.1
CommitLineData
c2d21bc3
WJ
1.\" Copyright 1980, 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the Institute of Electrical and Electronics Engineers, Inc.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\" notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\" notice, this list of conditions and the following disclaimer in the
14.\" documentation and/or other materials provided with the distribution.
15.\" 3. All advertising materials mentioning features or use of this software
16.\" must display the following acknowledgement:
17.\" This product includes software developed by the University of
18.\" California, Berkeley and its contributors.
19.\" 4. Neither the name of the University nor the names of its contributors
20.\" may be used to endorse or promote products derived from this software
21.\" without specific prior written permission.
22.\"
23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE.
34.\"
35.\" @(#)ls.1 6.18 (Berkeley) 6/27/91
36.\"
37.Dd June 27, 1991
38.Dt LS 1
39.Os
40.Sh NAME
41.Nm ls
42.Nd list directory contents.
43.Sh SYNOPSIS
44.Nm ls
45.Op Fl CFRacdilqrstu1
46.Op Ar file ...
47.Sh DESCRIPTION
48For each operand that names a
49.Ar file
50of a type other than
51directory,
52.Nm ls
53displays its name as well as any requested,
54associated information.
55For each operand that names a
56.Ar file
57of type directory,
58.Nm ls
59displays the names of files contained
60within that directory, as well as any requested, associated
61information.
62.Pp
63If no operands are given, the contents of the current
64directory are displayed.
65If more than one operand is given,
66non-directory operands are displayed first; directory
67and non-directory operands are sorted separately and in
68lexicographical order.
69.Pp
70The following options are available:
71.Bl -tag -width indent
72.It Fl A
73List all entries except for
74.Ql \&.
75and
76.Ql \&.. .
77Always set for the super-user.
78.It Fl C
79Force multi-column output; this is the default when output is to a terminal.
80.It Fl F
81Display a slash (/) immediately after each pathname
82that is a directory, an asterisk (*) after each that is
83executable,
84and an at sign (@) after each symbolic link.
85.\"and a vertical bar (|) after
86.\"each that is a
87.\".Tn FIFO .
88.It Fl L
89If argument is a symbolic link, list the file or directory the link references
90rather than the link itself.
91.It Fl R
92Recursively list subdirectories encountered.
93.It Fl T
94Display complete time information for the file, including
95month, day, hour, minute, second, and year.
96.It Fl a
97Include directory entries whose names begin with a
98dot (.).
99.It Fl c
100Use time when file status was last changed for sorting or printing.
101.It Fl d
102Directories are listed as plain files (not searched recursively).
103.It Fl f
104Output is not sorted.
105.It Fl g
106Include the group ownership of the file in a long
107.Pq Fl l
108output
109.Pq Fl lg .
110If the group is not a known group name, the numeric ID
111is printed.
112.It Fl i
113For each file, print the file's file serial number (inode number).
114.It Fl k
115Modifies the
116.Fl s
117option, causing the sizes to be reported in kilobytes.
118.It Fl l
119(The lowercase letter ``ell.'') List in long format. (See below.)
120If the output is to a terminal, a total sum for all the file
121sizes is output on a line before the long listing.
122.It Fl q
123Force printing of non-graphic characters in file names as
124the character `?'; this is the default when output is to a terminal.
125.It Fl r
126Reverse the order of the sort to get reverse
127lexicographical order or the oldest entries first.
128.It Fl s
129Display the number of file system bytes actually
130used by each file, in units of 512, where partial
131units are rounded up to the next integer value.
132If the output is to a terminal, a total sum for all the file
133sizes is output on a line before the listing.
134.It Fl t
135Sort by time modified (most recently modified
136first) before sorting the operands by lexicographical
137order.
138.It Fl u
139Use time of last access,
140instead of last modification
141of the file for sorting
142.Pq Fl t
143or printing
144.Pq Fl l .
145.It Fl \&1
146(The numeric digit ``one.'') Force output to be
147one entry per line.
148This is the default when
149output is not to a terminal.
150.El
151.Pp
152The
153.Fl 1 ,
154.Fl C ,
155and
156.Fl l
157options all override each other; the last one specified determines
158the format used.
159.Pp
160The
161.Fl c ,
162and
163.Fl u
164options override each other; the last one specified determines
165the file time used.
166.Pp
167By default,
168.Nm ls
169lists one entry per line to standard
170output; the exceptions are to terminals or when the
171.Fl C
172option is specified.
173.Pp
174File information is displayed with one or more
175<blank>s separating the information associated with the
176.Fl i ,
177.Fl s ,
178and
179.Fl l
180options.
181.Ss The Long Format
182If the
183.Fl l
184option is given, the following information
185is be displayed:
186file mode,
187number of links, owner name,
188.\" group name,
189number of bytes in the file, abbreviated
190month, day-of-month file was last modified,
191hour file last modified, minute file last
192modified, and the pathname.
193.Pp
194If the owner name is not a known user name
195the numeric ID is displayed.
196.Pp
197If the file is a character special or block special file,
198the major and minor device numbers for the file are displayed
199in the size field. If the file is a symbolic link the pathname of the
200linked-to file is preceded by
201.Dq \-> .
202.Pp
203The file mode printed under the -l option consists of the
204the entry type, owner permissions, and group permissions.
205The entry type character describes the type of file, as
206follows:
207.Pp
208.Bl -tag -width 4n -offset indent -compact
209.It Sy b
210Block special file.
211.It Sy c
212Character special file.
213.It Sy d
214Directory.
215.It Sy l
216Symbolic link.
217.It Sy s
218Socket link.
219.\" .It Sy p
220.\" .Tn FIFO .
221.It Sy \-
222Regular file.
223.El
224.Pp
225The next three fields
226are three characters each:
227owner permissions,
228group permissions, and
229other permissions.
230Each field has three character positions:
231.Bl -enum -offset indent
232.It
233If
234.Sy r ,
235the file is readable; if
236.Sy \- ,
237it is not readable.
238.It
239If
240.Sy w ,
241the file is writable; if
242.Sy \- ,
243it is not writable.
244.It
245The first of the following that applies:
246.Bl -tag -width 4n -offset indent
247.It Sy S
248If in the owner permissions, the file is not executable and
249set-user-ID mode is set.
250If in the group permissions, the file is not executable
251and set-group-ID mode is set.
252.It Sy s
253If in the owner permissions, the file is executable
254and set-user-ID mode is set.
255If in the group permissions, the file is executable
256and setgroup-ID mode is set.
257.It Sy x
258The file is executable or the directory is
259searchable.
260.It Sy \-
261The file is neither readable, writeable, exectutable,
262or set-user-ID or set-group-ID mode nor sticky. (See below.)
263.El
264.Pp
265These next two apply only to the third character in the last group
266(other permissions).
267.Bl -tag -width 4n -offset indent
268.It Sy T
269The sticky bit is set
270(mode
271.Li 1000 ) ,
272but not execute or search permission. (See
273.Xr chmod 1
274or
275.Xr sticky 8 . )
276.It Sy t
277The sticky bit is set (mode
278.Li 1000 ) ,
279and is searcheable or executable.
280(See
281.Xr chmod 1
282or
283.Xr sticky 8 . )
284.El
285.El
286.Pp
287The
288.Nm ls
289utility exits 0 on success, and >0 if an error occurs.
290.Sh ENVIRONMENT
291The following environment variables affect the execution of
292.Nm ls :
293.Bl -tag -width COLUMNS
294.It COLUMNS
295If this variable contains a string representing a
296decimal integer, it is used as the
297column position width for displaying
298multiple-text-column output.
299The
300.Nm ls
301utility calculates how
302many pathname text columns to display
303based on the width provided.
304(See
305.Fl C . )
306.El
307.Sh SEE ALSO
308.Xr chmod 1 ,
309.Xr sticky 8
310.Sh HISTORY
311A
312.Nm ls
313command appeared in
314.At v6 .
315.\" .Sh STANDARDS
316.\" .The
317.\" .Nm ls
318.\" function is expected to be
319.\" .Tn POSIX
320.\" 1003.2 compatible.