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
39 .Nd list directory contents
42 .Op Fl ABCFGHILPRSTUWZabcdfghiklmnopqrstuvwxy1\&,
43 .Op Fl -color Ns = Ns Ar when
47 For each operand that names a
52 displays its name as well as any requested,
53 associated information.
54 For each operand that names a
58 displays the names of files contained
59 within that directory, as well as any requested, associated
62 If no operands are given, the contents of the current
63 directory are displayed.
64 If more than one operand is given,
65 non-directory operands are displayed first; directory
66 and non-directory operands are sorted separately and in
67 lexicographical order.
69 The following options are available:
70 .Bl -tag -width indent
72 Include directory entries whose names begin with a
79 Automatically set for the super-user unless
83 Force printing of non-printable characters (as defined by
85 and current locale settings) in file names as
89 is the numeric value of the character in octal.
90 This option is not defined in
93 Force multi-column output; this is the default when output is to a terminal.
95 When printing in the long
99 to format the date and time output.
104 Depending on the choice of format string, this may result in a
105 different number of columns in the output.
106 This option overrides the
109 This option is not defined in
114 immediately after each pathname that is a directory,
117 after each that is executable,
120 after each symbolic link,
132 Enable colorized output.
133 This option is equivalent to defining
137 in the environment and setting
138 .Fl -color Ns = Ns Ar auto .
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 is the default when neither
262 For compatibility with GNU coreutils,
282 Directories are listed as plain files (not searched recursively).
284 Output is not sorted.
287 It also negates the effect of the
295 this option has no effect on the
305 format output without the file owner's name or number.
309 option, use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte
310 and Petabyte in order to reduce the number of digits to four or fewer
311 using base 2 for sizes.
312 This option is not defined in
315 For each file, print the file's file serial number (inode number).
317 This has the same effect as setting environment variable
319 to 1024, except that it also nullifies any
323 (The lowercase letter
325 List files in the long format, as described in the
329 Stream output format; list files across the page, separated by commas.
331 Display user and group IDs numerically rather than converting to a user
332 or group name in a long
336 Include the file flags in a long
339 This option is incompatible with
343 for a list of file flags and their meanings.
347 after each filename if that file is a directory.
349 Force printing of non-graphic characters in file names as
352 this is the default when output is to a terminal.
354 Reverse the order of the sort.
356 Display the number of blocks used in the file system by each file.
357 Block sizes and directory totals are handled as described in
359 subsection below, except (if the long format is not also requested)
360 the directory totals are not output when the output is in a
361 single column, even if multi-column output is requested.
363 Sort by descending time modified (most recently modified first).
364 If two files have the same modification timestamp, sort their names
365 in ascending lexicographical order.
368 option reverses both of these sort orders.
370 Note that these sort orders are contradictory: the time sequence is in
371 descending order, the lexicographical sort is in ascending order.
372 This behavior is mandated by
374 This feature can cause problems listing files stored with sequential names on
375 FAT file systems, such as from digital cameras, where it is possible to have
376 more than one image with the same timestamp.
377 In such a case, the photos cannot be listed in the sequence in which
379 To ensure the same sort order for time and for lexicographical sorting, set the
387 to reverse the lexicographical sort order when sorting files with the
388 same modification timestamp.
390 Use time of last access,
391 instead of time of last modification
392 of the file for sorting
397 Sort following a natural ordering, using
401 as the comparison function.
402 E.g., files lexicographically ordered
403 "bloem1", "bloem10", and "bloem9" would instead be ordered
404 "bloem1", "bloem9", and "bloem10", as one would perhaps expect.
406 Force raw printing of non-printable characters.
408 when output is not to a terminal.
409 This option is not defined in
414 except that the multi-column output is produced with entries sorted
415 across, rather than down, the columns.
419 option is set, sort the alphabetical output in the same order as the time output.
420 This has the same effect as setting
422 See the description of the
424 option for more details.
425 This option is not defined in
432 This is the default when
433 output is not to a terminal.
437 option is set, print file sizes grouped and separated by thousands using the
438 non-monetary separator returned by
440 typically a comma or period.
441 If no locale is set, or the locale does not have a non-monetary separator, this
442 option has no effect.
443 This option is not defined in
451 options all override each other; the last one specified determines
458 options all override each other; the last one specified determines
465 options override each other; the last one specified determines
472 options all override each other; the last one specified determines
473 the format used for non-printable characters.
479 options all override each other (either partially or fully); they
480 are applied in the order specified.
484 lists one entry per line to standard
485 output; the exceptions are to terminals or when the
489 options are specified.
491 File information is displayed with one or more
493 separating the information associated with the
501 option is given, the following information
502 is displayed for each file:
504 number of links, owner name, group name,
506 number of bytes in the file, abbreviated
507 month, day-of-month file was last modified,
508 hour file last modified, minute file last
509 modified, and the pathname.
511 If the modification time of the file is more than 6 months
512 in the past or future, and the
517 then the year of the last modification
518 is displayed in place of the hour and minute fields.
520 If the owner or group names are not a known user or group name,
524 the numeric ID's are displayed.
526 If the file is a character special or block special file,
527 the device number for the file is displayed in the size field.
528 If the file is a symbolic link the pathname of the
529 linked-to file is preceded by
532 The listing of a directory's contents is preceded
533 by a labeled total number of blocks used in the file system by the files
534 which are listed as the directory's contents
535 (which may or may not include
539 and other files which start with a dot, depending on other options).
541 The default block size is 512 bytes.
542 The block size may be set with option
544 or environment variable
546 Numbers of blocks in the output will have been rounded up so the
547 numbers of bytes is at least as many as used by the corresponding
548 file system blocks (which might have a different size).
550 The file mode printed under the
552 option consists of the
553 entry type and the permissions.
554 The entry type character describes the type of file, as
557 .Bl -tag -width 4n -offset indent -compact
563 Character special file.
576 The next three fields
577 are three characters each:
579 group permissions, and
581 Each field has three character positions:
582 .Bl -enum -offset indent
586 the file is readable; if
592 the file is writable; if
596 The first of the following that applies:
597 .Bl -tag -width 4n -offset indent
599 If in the owner permissions, the file is not executable and
600 set-user-ID mode is set.
601 If in the group permissions, the file is not executable
602 and set-group-ID mode is set.
604 If in the owner permissions, the file is executable
605 and set-user-ID mode is set.
606 If in the group permissions, the file is executable
607 and setgroup-ID mode is set.
609 The file is executable or the directory is
612 The file is neither readable, writable, executable,
613 nor set-user-ID nor set-group-ID mode, nor sticky.
617 These next two apply only to the third character in the last group
619 .Bl -tag -width 4n -offset indent
621 The sticky bit is set
624 but not execute or search permission.
630 The sticky bit is set (mode
632 and is searchable or executable.
640 The next field contains a
643 character if the file has an ACL, or a
649 utility does not show the actual ACL;
654 The following environment variables affect the execution of
656 .Bl -tag -width ".Ev CLICOLOR_FORCE"
658 If this is set, its value, rounded up to 512 or down to a
659 multiple of 512, will be used as the block size in bytes by the
666 subsection for more information.
670 color sequences to distinguish file types.
674 In addition to the file types mentioned in the
676 option some extra attributes (setuid bit set, etc.) are also displayed.
677 The colorization is dependent on a terminal type with the proper
682 console has the proper capabilities,
683 but to display the colors in an
684 .Xr xterm 1 Pq Pa ports/x11/xterm ,
688 variable must be set to
690 Other terminal types may require similar adjustments.
692 is silently disabled if the output is not directed to a terminal
695 variable is defined or
699 .It Ev CLICOLOR_FORCE
700 Color sequences are normally disabled if the output is not directed to
702 This can be overridden by setting this variable.
705 variable still needs to reference a color capable terminal however
706 otherwise it is not possible to determine which color sequences to
713 If this variable contains a string representing a
714 decimal integer, it is used as the
715 column position width for displaying
716 multiple-text-column output.
719 utility calculates how
720 many pathname text columns to display
721 based on the width provided.
727 The locale to use when determining the order of day and month in the long
732 for more information.
734 The value of this variable describes what color to use for which
735 attribute when colors are enabled with
739 This string is a concatenation of pairs of the format
743 is the foreground color and
745 is the background color.
746 When the background color is capitalized, the text is underlined.
748 The color designators are as follows:
750 .Bl -tag -width 4n -offset indent -compact
768 bold or underlined black, usually shows up as dark grey
770 bold or underlined red
772 bold or underlined green
774 bold or underlined brown, usually shows up as yellow
776 bold or underlined blue
778 bold or underlined magenta
780 bold or underlined cyan
782 bold or underlined light grey; looks like bright white
784 default foreground or background
786 default foreground or background, with an underline or bold
789 Note that the above are standard
792 The actual display may differ
793 depending on the color capabilities of the terminal in use.
795 The order of the attributes are as follows:
797 .Bl -enum -offset indent -compact
813 executable with setuid bit set
815 executable with setgid bit set
817 directory writable to others, with sticky bit
819 directory writable to others, without sticky bit
823 .Qq "exfxcxdxbxegedabagacad" ,
824 i.e., blue foreground and
825 default background for regular directories, black foreground and red
826 background for setuid executables, etc.
828 If this variable is set, it is considered to be a
829 colon-delimited list of minimum column widths.
831 and insufficient widths are ignored (thus zero signifies
832 a dynamically sized column).
833 Not all columns have changeable widths.
835 in order: inode, block count, number of links, user name,
836 group name, flags, file size, file name.
838 If this variable is set, the
840 option sorts the names of files with the same modification timestamp in the same
841 sense as the time sort.
842 See the description of the
844 option for more details.
850 functionality depends on a terminal type with color capabilities.
852 The timezone to use when displaying dates.
855 for more information.
860 List the contents of the current working directory in long format:
864 In addition to listing the contents of the current working directory in
865 long format, show inode numbers, file flags (see
867 and suffix each filename with a symbol representing its file type:
873 sorting the output such that the mostly recently modified entries are
876 .Dl $ ls -lt /var/log
878 The group field is now automatically included in the long listing for
879 files in order to be compatible with the
887 .Xr xterm 1 Pq Pa ports/x11/xterm ,
899 With the exception of options
910 .Fl B , D , G , I , T , U , W , Z , b , h , v , w , y
913 are non-standard extensions.
915 The ACL support is compatible with
918 .Pq Dq Tn POSIX Ns .2c
932 To maintain backward compatibility, the relationships between the many
933 options are quite complex.
935 The exception mentioned in the
937 option description might be a feature that was
938 based on the fact that single-column output
939 usually goes to something other than a terminal.
940 It is debatable whether this is a design bug.
943 mandates opposite sort orders for files with the same timestamp when