1.\" Copyright (c) 1980, 1990, 1991, 1993, 1994 2.\" The Regents of the University of California. 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 8.7 (Berkeley) 7/29/94 36.\" $FreeBSD$ 37.\" 38.Dd July 29, 1994 39.Dt LS 1 40.Os 41.Sh NAME 42.Nm ls 43.Nd list directory contents 44.Sh SYNOPSIS 45.Nm ls 46.Op Fl ACFLRTWacdfiloqrstu1 47.Op Ar file ... 48.Sh DESCRIPTION 49For each operand that names a 50.Ar file 51of a type other than 52directory, 53.Nm ls 54displays its name as well as any requested, 55associated information. 56For each operand that names a 57.Ar file 58of type directory, 59.Nm ls 60displays the names of files contained 61within that directory, as well as any requested, associated 62information. 63.Pp 64If no operands are given, the contents of the current 65directory are displayed. 66If more than one operand is given, 67non-directory operands are displayed first; directory 68and non-directory operands are sorted separately and in 69lexicographical order. 70.Pp 71The following options are available: 72.Bl -tag -width indent 73.It Fl A 74List all entries except for 75.Ql \&. 76and 77.Ql \&.. . 78Always set for the super-user. 79.It Fl C 80Force multi-column output; this is the default when output is to a terminal. 81.It Fl F 82Display a slash (/) immediately after each pathname 83that is a directory, an asterisk (*) after each that is 84executable, 85an at sign (@) after each symbolic link, 86an equals sign (=) after each socket, 87a percent sign (%) after each whiteout, 88and a vertical bar (|) after 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 W 99Display whiteouts when scanning directories. (UNIMPLEMENTED) 100.It Fl a 101Include directory entries whose names begin with a 102dot (.). 103.It Fl c 104Use time when file status was last changed for sorting or printing. 105.It Fl d 106Directories are listed as plain files (not searched recursively) and 107symbolic links in the argument list are not indirected through. 108.It Fl f 109Output is not sorted. 110.It Fl i 111For each file, print the file's file serial number (inode number). 112.It Fl k 113If the 114.Fl s 115option is specified, print the file size allocation in kilobytes, 116not blocks. 117.It Fl l 118(The lowercase letter ``ell.'') List in long format. (See below.) 119If the output is to a terminal, a total sum for all the file 120sizes is output on a line before the long listing. 121.It Fl o 122Include the file flags in a long 123.Pq Fl l 124output 125.It Fl q 126Force printing of non-graphic characters in file names as 127the character `?'; this is the default when output is to a terminal. 128.It Fl r 129Reverse the order of the sort to get reverse 130lexicographical order or the oldest entries first. 131.It Fl s 132Display the number of file system blocks actually used by each file, in units 133of 512 bytes, where partial units 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 displayed for each file: 188file mode, 189number of links, owner name, group name, 190number of bytes in the file, abbreviated 191month, day-of-month file was last modified, 192hour file last modified, minute file last 193modified, and the pathname. 194In addition, for each directory whose contents are displayed, the total 195number of 512-byte blocks used by the files in the directory is displayed 196on a line by itself immediately before the information for the files in the 197directory. 198.Pp 199If the modification time of the file is more than 6 months 200in the past or future, then the year of the last modification 201is displayed in place of the hour and minute fields. 202.Pp 203If the owner or group names are not a known user or group name 204the numeric ID's are displayed. 205.Pp 206If the file is a character special or block special file, 207the major and minor device numbers for the file are displayed 208in the size field. If the file is a symbolic link the pathname of the 209linked-to file is preceded by 210.Dq \-> . 211.Pp 212The file mode printed under the 213.Fl l 214option consists of the 215entry type, owner permissions, and group permissions. 216The entry type character describes the type of file, as 217follows: 218.Pp 219.Bl -tag -width 4n -offset indent -compact 220.It Sy b 221Block special file. 222.It Sy c 223Character special file. 224.It Sy d 225Directory. 226.It Sy l 227Symbolic link. 228.It Sy s 229Socket link. 230.It Sy p 231.Tn FIFO . 232.It Sy \- 233Regular file. 234.El 235.Pp 236The next three fields 237are three characters each: 238owner permissions, 239group permissions, and 240other permissions. 241Each field has three character positions: 242.Bl -enum -offset indent 243.It 244If 245.Sy r , 246the file is readable; if 247.Sy \- , 248it is not readable. 249.It 250If 251.Sy w , 252the file is writable; if 253.Sy \- , 254it is not writable. 255.It 256The first of the following that applies: 257.Bl -tag -width 4n -offset indent 258.It Sy S 259If in the owner permissions, the file is not executable and 260set-user-ID mode is set. 261If in the group permissions, the file is not executable 262and set-group-ID mode is set. 263.It Sy s 264If in the owner permissions, the file is executable 265and set-user-ID mode is set. 266If in the group permissions, the file is executable 267and setgroup-ID mode is set. 268.It Sy x 269The file is executable or the directory is 270searchable. 271.It Sy \- 272The file is neither readable, writeable, executable, 273nor set-user-ID nor set-group-ID mode, nor sticky. (See below.) 274.El 275.Pp 276These next two apply only to the third character in the last group 277(other permissions). 278.Bl -tag -width 4n -offset indent 279.It Sy T 280The sticky bit is set 281(mode 282.Li 1000 ) , 283but not execute or search permission. (See 284.Xr chmod 1 285or 286.Xr sticky 8 . ) 287.It Sy t 288The sticky bit is set (mode 289.Li 1000 ) , 290and is searchable or executable. 291(See 292.Xr chmod 1 293or 294.Xr sticky 8 . ) 295.El 296.El 297.Pp 298The 299.Nm ls 300utility exits 0 on success, and >0 if an error occurs. 301.Sh ENVIRONMENTAL VARIABLES 302The following environment variables affect the execution of 303.Nm ls : 304.Bl -tag -width BLOCKSIZE 305.It Ev BLOCKSIZE 306If the environmental variable 307.Ev BLOCKSIZE 308is set, the block counts 309(see 310.Fl s ) 311will be displayed in units of that size block. 312.It COLUMNS 313If this variable contains a string representing a 314decimal integer, it is used as the 315column position width for displaying 316multiple-text-column output. 317The 318.Nm ls 319utility calculates how 320many pathname text columns to display 321based on the width provided. 322(See 323.Fl C . ) 324.It Ev TZ 325The timezone to use when displaying dates. 326See 327.Xr environ 7 328for more information. 329.El 330.Sh COMPATIBILITY 331The group field is now automatically included in the long listing for 332files in order to be compatible with the 333.St -p1003.2 334specification. 335.Sh SEE ALSO 336.Xr chmod 1 , 337.Xr symlink 7 , 338.Xr sticky 8 339.Sh HISTORY 340An 341.Nm ls 342command appeared in 343.At v1 . 344.Sh STANDARDS 345The 346.Nm ls 347function is expected to be a superset of the 348.St -p1003.2 349specification. 350