This commit was manufactured by cvs2svn to create tag 'FreeBSD-release/1.0'.
[unix-history] / bin / ls / ls.1
CommitLineData
15637ed4
RG
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.\"
78ed81a3 37.\" $Header: /b/source/CVS/src/bin/ls/ls.1,v 1.3 1993/03/23 00:26:07 cgd Exp $
38.\"
15637ed4
RG
39.Dd June 27, 1991
40.Dt LS 1
41.Os
42.Sh NAME
43.Nm ls
44.Nd list directory contents.
45.Sh SYNOPSIS
46.Nm ls
47.Op Fl CFRacdilqrstu1
48.Op Ar file ...
49.Sh DESCRIPTION
50For each operand that names a
51.Ar file
52of a type other than
53directory,
54.Nm ls
55displays its name as well as any requested,
56associated information.
57For each operand that names a
58.Ar file
59of type directory,
60.Nm ls
61displays the names of files contained
62within that directory, as well as any requested, associated
63information.
64.Pp
65If no operands are given, the contents of the current
66directory are displayed.
67If more than one operand is given,
68non-directory operands are displayed first; directory
69and non-directory operands are sorted separately and in
70lexicographical order.
71.Pp
72The following options are available:
73.Bl -tag -width indent
74.It Fl A
75List all entries except for
76.Ql \&.
77and
78.Ql \&.. .
79Always set for the super-user.
80.It Fl C
81Force multi-column output; this is the default when output is to a terminal.
82.It Fl F
83Display a slash (/) immediately after each pathname
84that is a directory, an asterisk (*) after each that is
85executable,
86and an at sign (@) after each symbolic link.
87.\"and a vertical bar (|) after
88.\"each that is a
89.\".Tn FIFO .
90.It Fl L
91If argument is a symbolic link, list the file or directory the link references
92rather than the link itself.
93.It Fl R
94Recursively list subdirectories encountered.
95.It Fl T
96Display complete time information for the file, including
97month, day, hour, minute, second, and year.
98.It Fl a
99Include directory entries whose names begin with a
100dot (.).
101.It Fl c
102Use time when file status was last changed for sorting or printing.
103.It Fl d
104Directories are listed as plain files (not searched recursively).
105.It Fl f
106Output is not sorted.
107.It Fl g
108Include the group ownership of the file in a long
109.Pq Fl l
110output
111.Pq Fl lg .
112If the group is not a known group name, the numeric ID
113is printed.
114.It Fl i
115For each file, print the file's file serial number (inode number).
116.It Fl k
117Modifies the
118.Fl s
119option, causing the sizes to be reported in kilobytes.
120.It Fl l
121(The lowercase letter ``ell.'') List in long format. (See below.)
122If the output is to a terminal, a total sum for all the file
123sizes is output on a line before the long listing.
124.It Fl q
125Force printing of non-graphic characters in file names as
126the character `?'; this is the default when output is to a terminal.
127.It Fl r
128Reverse the order of the sort to get reverse
129lexicographical order or the oldest entries first.
130.It Fl s
131Display the number of file system bytes actually
132used by each file, in units of 512, where partial
133units are rounded up to the next integer value.
134If the output is to a terminal, a total sum for all the file
135sizes is output on a line before the listing.
136.It Fl t
137Sort by time modified (most recently modified
138first) before sorting the operands by lexicographical
139order.
140.It Fl u
141Use time of last access,
142instead of last modification
143of the file for sorting
144.Pq Fl t
145or printing
146.Pq Fl l .
147.It Fl \&1
148(The numeric digit ``one.'') Force output to be
149one entry per line.
150This is the default when
151output is not to a terminal.
152.El
153.Pp
154The
155.Fl 1 ,
156.Fl C ,
157and
158.Fl l
159options all override each other; the last one specified determines
160the format used.
161.Pp
162The
163.Fl c ,
164and
165.Fl u
166options override each other; the last one specified determines
167the file time used.
168.Pp
169By default,
170.Nm ls
171lists one entry per line to standard
172output; the exceptions are to terminals or when the
173.Fl C
174option is specified.
175.Pp
176File information is displayed with one or more
177<blank>s separating the information associated with the
178.Fl i ,
179.Fl s ,
180and
181.Fl l
182options.
183.Ss The Long Format
184If the
185.Fl l
186option is given, the following information
187is be displayed:
188file mode,
189number of links, owner name,
190.\" group name,
191number of bytes in the file, abbreviated
192month, day-of-month file was last modified,
193hour file last modified, minute file last
194modified, and the pathname.
195.Pp
196If the owner name is not a known user name
197the numeric ID is displayed.
198.Pp
199If the file is a character special or block special file,
200the major and minor device numbers for the file are displayed
201in the size field. If the file is a symbolic link the pathname of the
202linked-to file is preceded by
203.Dq \-> .
204.Pp
205The file mode printed under the -l option consists of the
206the entry type, owner permissions, and group permissions.
207The entry type character describes the type of file, as
208follows:
209.Pp
210.Bl -tag -width 4n -offset indent -compact
211.It Sy b
212Block special file.
213.It Sy c
214Character special file.
215.It Sy d
216Directory.
217.It Sy l
218Symbolic link.
219.It Sy s
220Socket link.
221.\" .It Sy p
222.\" .Tn FIFO .
223.It Sy \-
224Regular file.
225.El
226.Pp
227The next three fields
228are three characters each:
229owner permissions,
230group permissions, and
231other permissions.
232Each field has three character positions:
233.Bl -enum -offset indent
234.It
235If
236.Sy r ,
237the file is readable; if
238.Sy \- ,
239it is not readable.
240.It
241If
242.Sy w ,
243the file is writable; if
244.Sy \- ,
245it is not writable.
246.It
247The first of the following that applies:
248.Bl -tag -width 4n -offset indent
249.It Sy S
250If in the owner permissions, the file is not executable and
251set-user-ID mode is set.
252If in the group permissions, the file is not executable
253and set-group-ID mode is set.
254.It Sy s
255If in the owner permissions, the file is executable
256and set-user-ID mode is set.
257If in the group permissions, the file is executable
258and setgroup-ID mode is set.
259.It Sy x
260The file is executable or the directory is
261searchable.
262.It Sy \-
263The file is neither readable, writeable, exectutable,
264or set-user-ID or set-group-ID mode nor sticky. (See below.)
265.El
266.Pp
267These next two apply only to the third character in the last group
268(other permissions).
269.Bl -tag -width 4n -offset indent
270.It Sy T
271The sticky bit is set
272(mode
273.Li 1000 ) ,
274but not execute or search permission. (See
275.Xr chmod 1
276or
277.Xr sticky 8 . )
278.It Sy t
279The sticky bit is set (mode
280.Li 1000 ) ,
281and is searcheable or executable.
282(See
283.Xr chmod 1
284or
285.Xr sticky 8 . )
286.El
287.El
288.Pp
289The
290.Nm ls
291utility exits 0 on success, and >0 if an error occurs.
292.Sh ENVIRONMENT
293The following environment variables affect the execution of
294.Nm ls :
295.Bl -tag -width COLUMNS
296.It COLUMNS
297If this variable contains a string representing a
298decimal integer, it is used as the
299column position width for displaying
300multiple-text-column output.
301The
302.Nm ls
303utility calculates how
304many pathname text columns to display
305based on the width provided.
306(See
307.Fl C . )
308.El
309.Sh SEE ALSO
310.Xr chmod 1 ,
311.Xr sticky 8
312.Sh HISTORY
313A
314.Nm ls
315command appeared in
316.At v6 .
317.\" .Sh STANDARDS
318.\" .The
319.\" .Nm ls
320.\" function is expected to be
321.\" .Tn POSIX
322.\" 1003.2 compatible.