2 .\" Copyright (c) 1980, 1990, 1991, 1993, 1994
3 .\" The Regents of the University of California. All rights reserved.
5 .\" This code is derived from software contributed to Berkeley by
6 .\" the Institute of Electrical and Electronics Engineers, Inc.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)ls.1 8.7 (Berkeley) 7/29/94
40 .Nd list directory contents
43 .Op Fl ABCFGHILPRSTUWZabcdfghiklmnopqrstuwxy1,
44 .Op Fl -color Ns = Ns Ar when
48 For each operand that names a
53 displays its name as well as any requested,
54 associated information.
55 For each operand that names a
59 displays the names of files contained
60 within that directory, as well as any requested, associated
63 If no operands are given, the contents of the current
64 directory are displayed.
65 If more than one operand is given,
66 non-directory operands are displayed first; directory
67 and non-directory operands are sorted separately and in
68 lexicographical order.
70 The following options are available:
71 .Bl -tag -width indent
73 Include directory entries whose names begin with a
80 Automatically set for the super-user unless
84 Force printing of non-printable characters (as defined by
86 and current locale settings) in file names as
90 is the numeric value of the character in octal.
91 This option is not defined in
94 Force multi-column output; this is the default when output is to a terminal.
96 When printing in the long
100 to format the date and time output.
105 Depending on the choice of format string, this may result in a
106 different number of columns in the output.
107 This option overrides the
110 This option is not defined in
115 immediately after each pathname that is a directory,
118 after each that is executable,
121 after each symbolic link,
133 Enable colorized output.
134 This option is equivalent to defining
140 This functionality can be compiled out by removing the definition of
142 This option is not defined in
145 Symbolic links on the command line are followed.
146 This option is assumed if
151 options are specified.
155 from being automatically set for the super-user.
156 This option is not defined in
159 If argument is a symbolic link, list the file or directory the link references
160 rather than the link itself.
161 This option cancels the
165 If argument is a symbolic link, list the link itself rather than the
166 object the link references.
167 This option cancels the
173 Recursively list subdirectories encountered.
175 Sort by size (largest file first) before sorting the operands in
176 lexicographical order.
178 When printing in the long
180 format, display complete time information for the file, including
181 month, day, hour, minute, second, and year.
184 option gives even more control over the output format.
185 This option is not defined in
188 Use time when file was created for sorting or printing.
189 This option is not defined in
192 Display whiteouts when scanning directories.
193 This option is not defined in
196 Display each file's MAC label; see
198 This option is not defined in
201 Include directory entries whose names begin with a
209 escape codes whenever possible.
210 This option is not defined in
213 Use time when file status was last changed for sorting or printing.
214 .It Fl -color Ns = Ns Ar when
215 Output colored escape sequences based on
217 which may be set to either
229 is unset or set to an invalid terminal, then
231 will fall back to explicit
233 escape sequences without the help of
238 is specified without an argument.
243 output escape sequences based on
247 is a tty and either the
249 flag is specified or the
251 environment variable is set and not empty.
254 will disable color regardless of environment variables.
256 For compatibility with GNU coreutils,
276 Directories are listed as plain files (not searched recursively).
278 Output is not sorted.
281 It also negates the effect of the
289 this option has no effect on the
297 This option has no effect.
298 It is only available for compatibility with
300 where it was used to display the group name in the long
303 This option is incompatible with
308 option, use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte
309 and Petabyte in order to reduce the number of digits to four or fewer
310 using base 2 for sizes.
311 This option is not defined in
314 For each file, print the file's file serial number (inode number).
316 This has the same effect as setting environment variable
318 to 1024, except that it also nullifies any
322 (The lowercase letter
324 List files in the long format, as described in the
328 Stream output format; list files across the page, separated by commas.
330 Display user and group IDs numerically rather than converting to a user
331 or group name in a long
335 Include the file flags in a long
338 This option is incompatible with
342 for a list of file flags and their meanings.
346 after each filename if that file is a directory.
348 Force printing of non-graphic characters in file names as
351 this is the default when output is to a terminal.
353 Reverse the order of the sort.
355 Display the number of blocks used in the file system by each file.
356 Block sizes and directory totals are handled as described in
358 subsection below, except (if the long format is not also requested)
359 the directory totals are not output when the output is in a
360 single column, even if multi-column output is requested.
362 Sort by descending time modified (most recently modified first).
363 If two files have the same modification timestamp, sort their names
364 in ascending lexicographical order.
367 option reverses both of these sort orders.
369 Note that these sort orders are contradictory: the time sequence is in
370 descending order, the lexicographical sort is in ascending order.
371 This behavior is mandated by
373 This feature can cause problems listing files stored with sequential names on
374 FAT file systems, such as from digital cameras, where it is possible to have
375 more than one image with the same timestamp.
376 In such a case, the photos cannot be listed in the sequence in which
378 To ensure the same sort order for time and for lexicographical sorting, set the
386 to reverse the lexicographical sort order when sorting files with the
387 same modification timestamp.
389 Use time of last access,
390 instead of time of last modification
391 of the file for sorting
396 Force raw printing of non-printable characters.
398 when output is not to a terminal.
399 This option is not defined in
404 except that the multi-column output is produced with entries sorted
405 across, rather than down, the columns.
409 option is set, sort the alphabetical output in the same order as the time output.
410 This has the same effect as setting
412 See the description of the
414 option for more details.
415 This option is not defined in
422 This is the default when
423 output is not to a terminal.
427 option is set, print file sizes grouped and separated by thousands using the
428 non-monetary separator returned by
430 typically a comma or period.
431 If no locale is set, or the locale does not have a non-monetary separator, this
432 option has no effect.
433 This option is not defined in
441 options all override each other; the last one specified determines
448 options all override each other; the last one specified determines
455 options override each other; the last one specified determines
462 options all override each other; the last one specified determines
463 the format used for non-printable characters.
469 options all override each other (either partially or fully); they
470 are applied in the order specified.
474 lists one entry per line to standard
475 output; the exceptions are to terminals or when the
479 options are specified.
481 File information is displayed with one or more
483 separating the information associated with the
491 option is given, the following information
492 is displayed for each file:
494 number of links, owner name, group name,
496 number of bytes in the file, abbreviated
497 month, day-of-month file was last modified,
498 hour file last modified, minute file last
499 modified, and the pathname.
501 If the modification time of the file is more than 6 months
502 in the past or future, and the
507 then the year of the last modification
508 is displayed in place of the hour and minute fields.
510 If the owner or group names are not a known user or group name,
514 the numeric ID's are displayed.
516 If the file is a character special or block special file,
517 the device number for the file is displayed in the size field.
518 If the file is a symbolic link the pathname of the
519 linked-to file is preceded by
522 The listing of a directory's contents is preceded
523 by a labeled total number of blocks used in the file system by the files
524 which are listed as the directory's contents
525 (which may or may not include
529 and other files which start with a dot, depending on other options).
531 The default block size is 512 bytes.
532 The block size may be set with option
534 or environment variable
536 Numbers of blocks in the output will have been rounded up so the
537 numbers of bytes is at least as many as used by the corresponding
538 file system blocks (which might have a different size).
540 The file mode printed under the
542 option consists of the
543 entry type and the permissions.
544 The entry type character describes the type of file, as
547 .Bl -tag -width 4n -offset indent -compact
553 Character special file.
566 The next three fields
567 are three characters each:
569 group permissions, and
571 Each field has three character positions:
572 .Bl -enum -offset indent
576 the file is readable; if
582 the file is writable; if
586 The first of the following that applies:
587 .Bl -tag -width 4n -offset indent
589 If in the owner permissions, the file is not executable and
590 set-user-ID mode is set.
591 If in the group permissions, the file is not executable
592 and set-group-ID mode is set.
594 If in the owner permissions, the file is executable
595 and set-user-ID mode is set.
596 If in the group permissions, the file is executable
597 and setgroup-ID mode is set.
599 The file is executable or the directory is
602 The file is neither readable, writable, executable,
603 nor set-user-ID nor set-group-ID mode, nor sticky.
607 These next two apply only to the third character in the last group
609 .Bl -tag -width 4n -offset indent
611 The sticky bit is set
614 but not execute or search permission.
620 The sticky bit is set (mode
622 and is searchable or executable.
630 The next field contains a
633 character if the file has an ACL, or a
639 utility does not show the actual ACL;
644 The following environment variables affect the execution of
646 .Bl -tag -width ".Ev CLICOLOR_FORCE"
648 If this is set, its value, rounded up to 512 or down to a
649 multiple of 512, will be used as the block size in bytes by the
656 subsection for more information.
660 color sequences to distinguish file types.
664 In addition to the file types mentioned in the
666 option some extra attributes (setuid bit set, etc.) are also displayed.
667 The colorization is dependent on a terminal type with the proper
672 console has the proper capabilities,
673 but to display the colors in an
678 variable must be set to
680 Other terminal types may require similar adjustments.
682 is silently disabled if the output is not directed to a terminal
685 variable is defined or
689 .It Ev CLICOLOR_FORCE
690 Color sequences are normally disabled if the output is not directed to
692 This can be overridden by setting this variable.
695 variable still needs to reference a color capable terminal however
696 otherwise it is not possible to determine which color sequences to
703 If this variable contains a string representing a
704 decimal integer, it is used as the
705 column position width for displaying
706 multiple-text-column output.
709 utility calculates how
710 many pathname text columns to display
711 based on the width provided.
717 The locale to use when determining the order of day and month in the long
722 for more information.
724 The value of this variable describes what color to use for which
725 attribute when colors are enabled with
729 This string is a concatenation of pairs of the format
733 is the foreground color and
735 is the background color.
737 The color designators are as follows:
739 .Bl -tag -width 4n -offset indent -compact
757 bold black, usually shows up as dark grey
763 bold brown, usually shows up as yellow
771 bold light grey; looks like bright white
773 default foreground or background
776 Note that the above are standard
779 The actual display may differ
780 depending on the color capabilities of the terminal in use.
782 The order of the attributes are as follows:
784 .Bl -enum -offset indent -compact
800 executable with setuid bit set
802 executable with setgid bit set
804 directory writable to others, with sticky bit
806 directory writable to others, without sticky bit
810 .Qq "exfxcxdxbxegedabagacad" ,
811 i.e., blue foreground and
812 default background for regular directories, black foreground and red
813 background for setuid executables, etc.
815 If this variable is set, it is considered to be a
816 colon-delimited list of minimum column widths.
818 and insufficient widths are ignored (thus zero signifies
819 a dynamically sized column).
820 Not all columns have changeable widths.
822 in order: inode, block count, number of links, user name,
823 group name, flags, file size, file name.
825 If this variable is set, the
827 option sorts the names of files with the same modification timestamp in the same
828 sense as the time sort.
829 See the description of the
831 option for more details.
837 functionality depends on a terminal type with color capabilities.
839 The timezone to use when displaying dates.
842 for more information.
847 List the contents of the current working directory in long format:
851 In addition to listing the contents of the current working directory in
852 long format, show inode numbers, file flags (see
854 and suffix each filename with a symbol representing its file type:
860 sorting the output such that the mostly recently modified entries are
863 .Dl $ ls -lt /var/log
865 The group field is now automatically included in the long listing for
866 files in order to be compatible with the
884 With the exception of options
893 .Fl B , D , G , I , T , U , W , Z , b , h , w , y
896 are compatible extensions not defined in
899 The ACL support is compatible with
902 .Pq Dq Tn POSIX Ns .2c
911 To maintain backward compatibility, the relationships between the many
912 options are quite complex.
914 The exception mentioned in the
916 option description might be a feature that was
917 based on the fact that single-column output
918 usually goes to something other than a terminal.
919 It is debatable whether this is a design bug.
922 mandates opposite sort orders for files with the same timestamp when