1 .\" Copyright (c) 1980, 1990, 1991, 1993, 1994
2 .\" The Regents of the University of California. All rights reserved.
4 .\" This code is derived from software contributed to Berkeley by
5 .\" the Institute of Electrical and Electronics Engineers, Inc.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
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 .\" 4. Neither the name of the University nor the names of its contributors
16 .\" may be used to endorse or promote products derived from this software
17 .\" without specific prior written permission.
19 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .\" @(#)ls.1 8.7 (Berkeley) 7/29/94
32 .\" $FreeBSD: src/bin/ls/ls.1,v 1.86 2005/02/13 22:25:09 ru Exp $
33 .\" $DragonFly: src/bin/ls/ls.1,v 1.5 2005/09/18 20:55:20 asmodai Exp $
40 .Nd list directory contents
43 .Op Fl ABCFGHLPRTWabcdfghiklmnopqrstuwxy1
46 For each operand that names a
51 displays its name as well as any requested,
52 associated information.
53 For each operand that names a
57 displays the names of files contained
58 within that directory, as well as any requested, associated
61 If no operands are given, the contents of the current
62 directory are displayed.
63 If more than one operand is given,
64 non-directory operands are displayed first; directory
65 and non-directory operands are sorted separately and in
66 lexicographical order.
68 The following options are available:
69 .Bl -tag -width indent
71 List all entries except for
75 Always set for the super-user.
77 Force printing of non-printable characters (as defined by
79 and current locale settings) in file names as
83 is the numeric value of the character in octal.
85 Force multi-column output; this is the default when output is to a terminal.
89 immediately after each pathname that is a directory,
92 after each that is executable,
95 after each symbolic link,
107 Enable colorized output.
108 This option is equivalent to defining
113 Symbolic links on the command line are followed.
114 This option is assumed if
119 options are specified.
121 If argument is a symbolic link, list the file or directory the link references
122 rather than the link itself.
123 This option cancels the
127 If argument is a symbolic link, list the link itself rather than the
128 object the link references.
129 This option cancels the
135 Recursively list subdirectories encountered.
141 option, display complete time information for the file, including
142 month, day, hour, minute, second, and year.
144 Display whiteouts when scanning directories.
146 Include directory entries whose names begin with a
154 escape codes whenever possible.
156 Use time when file status was last changed for sorting or printing.
158 Directories are listed as plain files (not searched recursively).
160 Output is not sorted.
162 This option is deprecated and is only available for compatibility
165 it was used to display the group name in the long
171 option, use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte
172 and Petabyte in order to reduce the number of digits to four or fewer
173 using base 2 for sizes.
175 For each file, print the file's file serial number (inode number).
179 option is specified, print the file size allocation in kilobytes,
181 This option overrides the environment variable
185 is mutually exclusive to
192 (The lowercase letter
196 A total sum (in blocks, see the
198 option for the block size unit) for all the file
199 sizes is output on a line before the long listing.
201 Stream output format; list files across the page, separated by commas.
203 Display user and group IDs numerically rather than converting to a user
204 or group name in a long
208 Include the file flags in a long
214 after each filename if that file is a directory.
216 Force printing of non-graphic characters in file names as
219 this is the default when output is to a terminal.
221 Reverse the order of the sort to get reverse
222 lexicographical order or the oldest entries first.
224 Display the number of file system blocks actually used by each file, in units
225 of 512 bytes, where partial units are rounded up to the next integer value.
226 A total sum for all the file
227 sizes is output on a line before the listing.
228 The environment variable
230 overrides the unit size of 512 bytes.
232 Sort by time modified (most recently modified
233 first) before sorting the operands by lexicographical
236 Use time of last access,
237 instead of last modification
238 of the file for sorting
243 Force raw printing of non-printable characters.
245 when output is not to a terminal.
249 except that the multi-column output is produced with entries sorted
250 across, rather than down, the columns.
252 Include the FSMID field in a long
260 This is the default when
261 output is not to a terminal.
268 options all override each other; the last one specified determines
275 options override each other; the last one specified determines
282 options all override each other; the last one specified determines
283 the format used for non-printable characters.
289 options all override each other (either partially or fully); they
290 are applied in the order specified.
294 lists one entry per line to standard
295 output; the exceptions are to terminals or when the
299 options are specified.
301 File information is displayed with one or more
303 separating the information associated with the
311 option is given, the following information
312 is displayed for each file:
314 number of links, owner name, group name,
315 number of bytes in the file, abbreviated
316 month, day-of-month file was last modified,
317 hour file last modified, minute file last
318 modified, and the pathname.
319 In addition, for each directory whose contents are displayed, the total
320 number of 512-byte blocks used by the files in the directory is displayed
321 on a line by itself immediately before the information for the files in the
324 If the modification time of the file is more than 6 months
325 in the past or future, then the year of the last modification
326 is displayed in place of the hour and minute fields.
328 If the owner or group names are not a known user or group name,
332 the numeric ID's are displayed.
334 If the file is a character special or block special file,
335 the major and minor device numbers for the file are displayed
337 If the file is a symbolic link the pathname of the
338 linked-to file is preceded by
341 The file mode printed under the
343 option consists of the
344 entry type and the permissions.
345 The entry type character describes the type of file, as
348 .Bl -tag -width 4n -offset indent -compact
352 Character special file.
365 The next three fields
366 are three characters each:
368 group permissions, and
370 Each field has three character positions:
371 .Bl -enum -offset indent
375 the file is readable; if
381 the file is writable; if
385 The first of the following that applies:
386 .Bl -tag -width 4n -offset indent
388 If in the owner permissions, the file is not executable and
389 set-user-ID mode is set.
390 If in the group permissions, the file is not executable
391 and set-group-ID mode is set.
393 If in the owner permissions, the file is executable
394 and set-user-ID mode is set.
395 If in the group permissions, the file is executable
396 and setgroup-ID mode is set.
398 The file is executable or the directory is
401 The file is neither readable, writable, executable,
402 nor set-user-ID nor set-group-ID mode, nor sticky.
406 These next two apply only to the third character in the last group
408 .Bl -tag -width 4n -offset indent
410 The sticky bit is set
413 but not execute or search permission.
419 The sticky bit is set (mode
421 and is searchable or executable.
429 The following environment variables affect the execution of
431 .Bl -tag -width ".Ev CLICOLOR_FORCE"
433 If the environment variable
435 is set, the block counts
438 will be displayed in units of that size block.
442 color sequences to distinguish file types.
446 In addition to the file types mentioned in the
448 option some extra attributes (setuid bit set, etc.) are also displayed.
449 The colorization is dependent on a terminal type with the proper
454 console has the proper capabilities,
455 but to display the colors in an
460 variable must be set to
462 Other terminal types may require similar adjustments.
464 is silently disabled if the output is not directed to a terminal
468 .It Ev CLICOLOR_FORCE
469 Color sequences are normally disabled if the output is not directed to
471 This can be overridden by setting this flag.
474 variable still needs to reference a color capable terminal however
475 otherwise it is not possible to determine which color sequences to
478 If this variable contains a string representing a
479 decimal integer, it is used as the
480 column position width for displaying
481 multiple-text-column output.
484 utility calculates how
485 many pathname text columns to display
486 based on the width provided.
492 The locale to use when determining the order of day and month in the long
497 for more information.
499 The value of this variable describes what color to use for which
500 attribute when colors are enabled with
502 This string is a concatenation of pairs of the format
506 is the foreground color and
508 is the background color.
510 The color designators are as follows:
512 .Bl -tag -width 4n -offset indent -compact
530 bold black, usually shows up as dark grey
536 bold brown, usually shows up as yellow
544 bold light grey; looks like bright white
546 default foreground or background
549 Note that the above are standard
552 The actual display may differ
553 depending on the color capabilities of the terminal in use.
555 The order of the attributes are as follows:
557 .Bl -enum -offset indent -compact
573 executable with setuid bit set
575 executable with setgid bit set
577 directory writable to others, with sticky bit
579 directory writable to others, without sticky bit
583 .Qq "exfxcxdxbxegedabagacad" ,
584 i.e., blue foreground and
585 default background for regular directories, black foreground and red
586 background for setuid executables, etc.
588 If this variable is set, it is considered to be a
589 colon-delimited list of minimum column widths.
591 and insufficient widths are ignored (thus zero signifies
592 a dynamically sized column).
593 Not all columns have changeable widths.
595 in order: inode, block count, number of links, user name,
596 group name, flags, file size, file name.
600 functionality depends on a terminal type with color capabilities.
602 The timezone to use when displaying dates.
605 for more information.
608 The following is how to do an
610 listing sorted by size (and shows why
612 does not need a separate option for this):
614 .Dl "ls -l | sort -n +4"
621 to get the results sorted from largest to smallest (a reverse sort).
623 The group field is now automatically included in the long listing for
624 files in order to be compatible with the
636 With the exception of options
651 To maintain backward compatibility, the relationships between the many
652 options are quite complex.