xref: /csrg-svn/bin/ls/ls.1 (revision 67580)
166907Sbostic.\" Copyright (c) 1980, 1990, 1991, 1993, 1994
260671Sbostic.\"	The Regents of the University of California.  All rights reserved.
319194Smckusick.\"
450195Sbostic.\" This code is derived from software contributed to Berkeley by
550195Sbostic.\" the Institute of Electrical and Electronics Engineers, Inc.
650195Sbostic.\"
748719Scael.\" %sccs.include.redist.roff%
819194Smckusick.\"
9*67580Spendry.\"     @(#)ls.1	8.7 (Berkeley) 07/29/94
1047842Sbostic.\"
1148719Scael.Dd
1248719Scael.Dt LS 1
1348719Scael.Os
1448719Scael.Sh NAME
1548719Scael.Nm ls
1648719Scael.Nd list directory contents
1748719Scael.Sh SYNOPSIS
1848719Scael.Nm ls
19*67580Spendry.Op Fl ACFLRTWacdfiloqrstu1
2048719Scael.Op Ar file ...
2148719Scael.Sh DESCRIPTION
2248719ScaelFor each operand that names a
2348719Scael.Ar file
2448719Scaelof a type other than
2548719Scaeldirectory,
2648719Scael.Nm ls
2748719Scaeldisplays its name as well as any requested,
2848719Scaelassociated information.
2948719ScaelFor each operand that names a
3048719Scael.Ar file
3148719Scaelof type directory,
3248719Scael.Nm ls
3348719Scaeldisplays the names of files contained
3448719Scaelwithin that directory, as well as any requested, associated
3548719Scaelinformation.
3648719Scael.Pp
3748719ScaelIf no operands are given, the contents of the current
3848719Scaeldirectory are displayed.
3948719ScaelIf more than one operand is given,
4048719Scaelnon-directory operands are displayed first; directory
4148719Scaeland non-directory operands are sorted separately and in
4248719Scaellexicographical order.
4348719Scael.Pp
4448719ScaelThe following options are available:
4548719Scael.Bl -tag -width indent
4648719Scael.It Fl A
4748719ScaelList all entries except for
4848719Scael.Ql \&.
4948719Scaeland
5048719Scael.Ql \&.. .
5138717SbosticAlways set for the super-user.
5248719Scael.It Fl C
5348719ScaelForce multi-column output; this is the default when output is to a terminal.
5448719Scael.It Fl F
5548719ScaelDisplay a slash (/) immediately after each pathname
5648719Scaelthat is a directory, an asterisk (*) after each that is
5748719Scaelexecutable,
58*67580Spendryan at sign (@) after each symbolic link,
59*67580Spendryand a percent sign (%) after each whiteout.
6052778Sbostic.\" and a vertical bar (|) after each that is a
6152778Sbostic.\" .Tn FIFO .
6248719Scael.It Fl L
6348719ScaelIf argument is a symbolic link, list the file or directory the link references
6448719Scaelrather than the link itself.
6548719Scael.It Fl R
6648719ScaelRecursively list subdirectories encountered.
6748719Scael.It Fl T
6848719ScaelDisplay complete time information for the file, including
6948719Scaelmonth, day, hour, minute, second, and year.
70*67580Spendry.It Fl W
71*67580SpendryDisplay whiteouts when scanning directories.
7248719Scael.It Fl a
7348719ScaelInclude directory entries whose names begin with a
7448719Scaeldot (.).
7548719Scael.It Fl c
7638717SbosticUse time when file status was last changed for sorting or printing.
7748719Scael.It Fl d
7852342SbosticDirectories are listed as plain files (not searched recursively) and
7952342Sbosticsymbolic links in the argument list are not indirected through.
8048719Scael.It Fl f
8148719ScaelOutput is not sorted.
8248719Scael.It Fl i
8348719ScaelFor each file, print the file's file serial number (inode number).
8448719Scael.It Fl l
8548719Scael(The lowercase letter ``ell.'')  List in long format. (See below.)
8648719ScaelIf the output is to a terminal, a total sum for all the file
8748719Scaelsizes is output on a line before the long listing.
8852900Sbostic.It Fl o
8951901SmckusickInclude the file flags in a long
9051901Smckusick.Pq Fl l
9151901Smckusickoutput
9248719Scael.It Fl q
9348719ScaelForce printing of non-graphic characters in file names as
9438717Sbosticthe character `?'; this is the default when output is to a terminal.
9548719Scael.It Fl r
9648719ScaelReverse the order of the sort to get reverse
9748719Scaellexicographical order or the oldest entries first.
9848719Scael.It Fl s
9952778SbosticDisplay the number of file system blocks actually used by each file, in units
10052778Sbosticof 512 bytes, where partial units are rounded up to the next integer value.
10148719ScaelIf the output is to a terminal, a total sum for all the file
10248719Scaelsizes is output on a line before the listing.
10348719Scael.It Fl t
10448719ScaelSort by time modified (most recently modified
10548719Scaelfirst) before sorting the operands by lexicographical
10648719Scaelorder.
10748719Scael.It Fl u
10848719ScaelUse time of last access,
10948719Scaelinstead of last modification
11048719Scaelof the file for sorting
11148719Scael.Pq Fl t
11248719Scaelor printing
11348719Scael.Pq Fl l .
11448719Scael.It Fl \&1
11548719Scael(The numeric digit ``one.'')  Force output to be
11648719Scaelone entry per line.
11748719ScaelThis is the default when
11848719Scaeloutput is not to a terminal.
11948719Scael.El
12048719Scael.Pp
12138717SbosticThe
12248719Scael.Fl 1 ,
12348719Scael.Fl C ,
12438717Sbosticand
12548719Scael.Fl l
12638717Sbosticoptions all override each other; the last one specified determines
12738717Sbosticthe format used.
12848719Scael.Pp
12938717SbosticThe
13048719Scael.Fl c ,
13138717Sbosticand
13248719Scael.Fl u
13338717Sbosticoptions override each other; the last one specified determines
13438717Sbosticthe file time used.
13548719Scael.Pp
13648719ScaelBy default,
13748719Scael.Nm ls
13848719Scaellists one entry per line to standard
13948719Scaeloutput; the exceptions are to terminals or when the
14048719Scael.Fl C
14148719Scaeloption is specified.
14248719Scael.Pp
14348719ScaelFile information is displayed with one or more
14448719Scael<blank>s separating the information associated with the
14548719Scael.Fl i ,
14648719Scael.Fl s ,
14748719Scaeland
14848719Scael.Fl l
14948719Scaeloptions.
15048719Scael.Ss The Long Format
15148719ScaelIf the
15248719Scael.Fl l
15348719Scaeloption is given, the following information
15452778Sbosticis displayed for each file:
15548719Scaelfile mode,
15652895Sbosticnumber of links, owner name, group name,
15748719Scaelnumber of bytes in the file, abbreviated
15848719Scaelmonth, day-of-month file was last modified,
15948719Scaelhour file last modified, minute file last
16048719Scaelmodified, and the pathname.
16152778SbosticIn addition, for each directory whose contents are displayed, the total
16252778Sbosticnumber of 512-byte blocks used by the files in the directory is displayed
16352778Sbosticon a line by itself immediately before the information for the files in the
16452778Sbosticdirectory.
16548719Scael.Pp
16652895SbosticIf the owner or group names are not a known user or group name
16752895Sbosticthe numeric ID's are displayed.
16848719Scael.Pp
16948719ScaelIf the file is a character special or block special file,
17048719Scaelthe major and minor device numbers for the file are displayed
17148719Scaelin the size field. If the file is a symbolic link the pathname of the
17248719Scaellinked-to file is preceded by
17348719Scael.Dq \-> .
17448719Scael.Pp
17548719ScaelThe file mode printed under the -l option consists of the
17665227Smckusickentry type, owner permissions, and group permissions.
17748719ScaelThe entry type character describes the type of file, as
17848719Scaelfollows:
17948719Scael.Pp
18048719Scael.Bl -tag -width 4n -offset indent -compact
18148719Scael.It Sy b
18248719ScaelBlock special file.
18348719Scael.It Sy c
18448719ScaelCharacter special file.
18548719Scael.It Sy d
18648719ScaelDirectory.
18748719Scael.It Sy l
18848719ScaelSymbolic link.
18948719Scael.It Sy s
19048719ScaelSocket link.
19148719Scael.\" .It Sy p
19248719Scael.\" .Tn FIFO .
193*67580Spendry.It Sy w
194*67580SpendryWhiteout.
19548719Scael.It Sy \-
19648719ScaelRegular file.
19748719Scael.El
19848719Scael.Pp
19948719ScaelThe next three fields
20048719Scaelare three characters each:
20148719Scaelowner permissions,
20248719Scaelgroup permissions, and
20348719Scaelother permissions.
20448719ScaelEach field has three character positions:
20548719Scael.Bl -enum -offset indent
20648719Scael.It
20748719ScaelIf
20848719Scael.Sy r ,
20948719Scaelthe file is readable; if
21048719Scael.Sy \- ,
21148719Scaelit is not readable.
21248719Scael.It
21348719ScaelIf
21448719Scael.Sy w ,
21548719Scaelthe file is writable; if
21648719Scael.Sy \- ,
21748719Scaelit is not writable.
21848719Scael.It
21948719ScaelThe first of the following that applies:
22048719Scael.Bl -tag -width 4n -offset indent
22148719Scael.It Sy S
22248719ScaelIf in the owner permissions, the file is not executable and
22348719Scaelset-user-ID mode is set.
22448719ScaelIf in the group permissions, the file is not executable
22548719Scaeland set-group-ID mode is set.
22648719Scael.It Sy s
22748719ScaelIf in the owner permissions, the file is executable
22848719Scaeland set-user-ID mode is set.
22948719ScaelIf in the group permissions, the file is executable
23048719Scaeland setgroup-ID mode is set.
23148719Scael.It Sy x
23248719ScaelThe file is executable or the directory is
23348719Scaelsearchable.
23448719Scael.It Sy \-
23565227SmckusickThe file is neither readable, writeable, executable,
23665227Smckusicknor set-user-ID nor set-group-ID mode, nor sticky. (See below.)
23748719Scael.El
23848719Scael.Pp
23948719ScaelThese next two apply only to the third character in the last group
24048719Scael(other permissions).
24148719Scael.Bl -tag -width 4n -offset indent
24248719Scael.It Sy T
24348719ScaelThe sticky bit is set
24448719Scael(mode
24548719Scael.Li 1000 ) ,
24648719Scaelbut not execute or search permission. (See
24748719Scael.Xr chmod 1
24848719Scaelor
24948719Scael.Xr sticky 8 . )
25048719Scael.It Sy t
25148719ScaelThe sticky bit is set (mode
25248719Scael.Li 1000 ) ,
25366907Sbosticand is searchable or executable.
25448719Scael(See
25548719Scael.Xr chmod 1
25648719Scaelor
25748719Scael.Xr sticky 8 . )
25848719Scael.El
25948719Scael.El
26048719Scael.Pp
26148719ScaelThe
26248719Scael.Nm ls
26348719Scaelutility exits 0 on success, and >0 if an error occurs.
26452778Sbostic.Sh ENVIRONMENTAL VARIABLES
26548719ScaelThe following environment variables affect the execution of
26648719Scael.Nm ls :
26752778Sbostic.Bl -tag -width BLOCKSIZE
26852778Sbostic.It Ev BLOCKSIZE
26952778SbosticIf the environmental variable
27052778Sbostic.Ev BLOCKSIZE
27152778Sbosticis set, the block counts
27252778Sbostic(see
27352778Sbostic.Fl s )
27452778Sbosticwill be displayed in units of that size block.
27548719Scael.It COLUMNS
27648719ScaelIf this variable contains a string representing a
27748719Scaeldecimal integer, it is used as the
27848719Scaelcolumn position width for displaying
27948719Scaelmultiple-text-column output.
28048719ScaelThe
28148719Scael.Nm ls
28248719Scaelutility calculates how
28348719Scaelmany pathname text columns to display
28448719Scaelbased on the width provided.
28548719Scael(See
28648719Scael.Fl C . )
28764911Sbostic.It Ev TZ
28864911SbosticThe timezone to use when displaying dates.
28964911SbosticSee
29064911Sbostic.Xr environ 7
29164911Sbosticfor more information.
29248719Scael.El
29352895Sbostic.Sh COMPATIBILITY
29452895SbosticThe group field is now automatically included in the long listing for
29552895Sbosticfiles in order to be compatible with the
29652895Sbostic.St -p1003.2
29752895Sbosticspecification.
29848719Scael.Sh SEE ALSO
29948719Scael.Xr chmod 1 ,
30055732Sbostic.Xr symlink 7 ,
30148719Scael.Xr sticky 8
30248719Scael.Sh HISTORY
30365227SmckusickAn
30448719Scael.Nm ls
30548719Scaelcommand appeared in
30648719Scael.At v6 .
30752778Sbostic.Sh STANDARDS
30852778SbosticThe
30952778Sbostic.Nm ls
31052778Sbosticfunction is expected to be a superset of the
31152778Sbostic.St -p1003.2
31252778Sbosticspecification.
313