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 ABCFGHILPRSTUWZabcdfghiklmnopqrstuvwxy1\&,
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
138 in the environment and setting
139 .Fl -color Ns = Ns Ar auto .
141 This functionality can be compiled out by removing the definition of
143 This option is not defined in
146 Symbolic links on the command line are followed.
147 This option is assumed if
152 options are specified.
156 from being automatically set for the super-user.
157 This option is not defined in
160 If argument is a symbolic link, list the file or directory the link references
161 rather than the link itself.
162 This option cancels the
166 If argument is a symbolic link, list the link itself rather than the
167 object the link references.
168 This option cancels the
174 Recursively list subdirectories encountered.
176 Sort by size (largest file first) before sorting the operands in
177 lexicographical order.
179 When printing in the long
181 format, display complete time information for the file, including
182 month, day, hour, minute, second, and year.
185 option gives even more control over the output format.
186 This option is not defined in
189 Use time when file was created for sorting or printing.
190 This option is not defined in
193 Display whiteouts when scanning directories.
194 This option is not defined in
197 Display each file's MAC label; see
199 This option is not defined in
202 Include directory entries whose names begin with a
210 escape codes whenever possible.
211 This option is not defined in
214 Use time when file status was last changed for sorting or printing.
215 .It Fl -color Ns = Ns Ar when
216 Output colored escape sequences based on
218 which may be set to either
230 is unset or set to an invalid terminal, then
232 will fall back to explicit
234 escape sequences without the help of
239 is specified without an argument.
244 output escape sequences based on
248 is a tty and either the
250 flag is specified or the
252 environment variable is set and not empty.
255 will disable color regardless of environment variables.
257 is the default when neither
263 For compatibility with GNU coreutils,
283 Directories are listed as plain files (not searched recursively).
285 Output is not sorted.
288 It also negates the effect of the
296 this option has no effect on the
304 This option has no effect.
305 It is only available for compatibility with
307 where it was used to display the group name in the long
310 This option is incompatible with
315 option, use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte
316 and Petabyte in order to reduce the number of digits to four or fewer
317 using base 2 for sizes.
318 This option is not defined in
321 For each file, print the file's file serial number (inode number).
323 This has the same effect as setting environment variable
325 to 1024, except that it also nullifies any
329 (The lowercase letter
331 List files in the long format, as described in the
335 Stream output format; list files across the page, separated by commas.
337 Display user and group IDs numerically rather than converting to a user
338 or group name in a long
342 Include the file flags in a long
345 This option is incompatible with
349 for a list of file flags and their meanings.
353 after each filename if that file is a directory.
355 Force printing of non-graphic characters in file names as
358 this is the default when output is to a terminal.
360 Reverse the order of the sort.
362 Display the number of blocks used in the file system by each file.
363 Block sizes and directory totals are handled as described in
365 subsection below, except (if the long format is not also requested)
366 the directory totals are not output when the output is in a
367 single column, even if multi-column output is requested.
369 Sort by descending time modified (most recently modified first).
370 If two files have the same modification timestamp, sort their names
371 in ascending lexicographical order.
374 option reverses both of these sort orders.
376 Note that these sort orders are contradictory: the time sequence is in
377 descending order, the lexicographical sort is in ascending order.
378 This behavior is mandated by
380 This feature can cause problems listing files stored with sequential names on
381 FAT file systems, such as from digital cameras, where it is possible to have
382 more than one image with the same timestamp.
383 In such a case, the photos cannot be listed in the sequence in which
385 To ensure the same sort order for time and for lexicographical sorting, set the
393 to reverse the lexicographical sort order when sorting files with the
394 same modification timestamp.
396 Use time of last access,
397 instead of time of last modification
398 of the file for sorting
403 Sort following a natural ordering, using
407 as the comparison function.
408 E.g., files lexicographically ordered
409 "bloem1", "bloem10", and "bloem9" would instead be ordered
410 "bloem1", "bloem9", and "bloem10", as one would perhaps expect.
412 Force raw printing of non-printable characters.
414 when output is not to a terminal.
415 This option is not defined in
420 except that the multi-column output is produced with entries sorted
421 across, rather than down, the columns.
425 option is set, sort the alphabetical output in the same order as the time output.
426 This has the same effect as setting
428 See the description of the
430 option for more details.
431 This option is not defined in
438 This is the default when
439 output is not to a terminal.
443 option is set, print file sizes grouped and separated by thousands using the
444 non-monetary separator returned by
446 typically a comma or period.
447 If no locale is set, or the locale does not have a non-monetary separator, this
448 option has no effect.
449 This option is not defined in
457 options all override each other; the last one specified determines
464 options all override each other; the last one specified determines
471 options override each other; the last one specified determines
478 options all override each other; the last one specified determines
479 the format used for non-printable characters.
485 options all override each other (either partially or fully); they
486 are applied in the order specified.
490 lists one entry per line to standard
491 output; the exceptions are to terminals or when the
495 options are specified.
497 File information is displayed with one or more
499 separating the information associated with the
507 option is given, the following information
508 is displayed for each file:
510 number of links, owner name, group name,
512 number of bytes in the file, abbreviated
513 month, day-of-month file was last modified,
514 hour file last modified, minute file last
515 modified, and the pathname.
517 If the modification time of the file is more than 6 months
518 in the past or future, and the
523 then the year of the last modification
524 is displayed in place of the hour and minute fields.
526 If the owner or group names are not a known user or group name,
530 the numeric ID's are displayed.
532 If the file is a character special or block special file,
533 the device number for the file is displayed in the size field.
534 If the file is a symbolic link the pathname of the
535 linked-to file is preceded by
538 The listing of a directory's contents is preceded
539 by a labeled total number of blocks used in the file system by the files
540 which are listed as the directory's contents
541 (which may or may not include
545 and other files which start with a dot, depending on other options).
547 The default block size is 512 bytes.
548 The block size may be set with option
550 or environment variable
552 Numbers of blocks in the output will have been rounded up so the
553 numbers of bytes is at least as many as used by the corresponding
554 file system blocks (which might have a different size).
556 The file mode printed under the
558 option consists of the
559 entry type and the permissions.
560 The entry type character describes the type of file, as
563 .Bl -tag -width 4n -offset indent -compact
569 Character special file.
582 The next three fields
583 are three characters each:
585 group permissions, and
587 Each field has three character positions:
588 .Bl -enum -offset indent
592 the file is readable; if
598 the file is writable; if
602 The first of the following that applies:
603 .Bl -tag -width 4n -offset indent
605 If in the owner permissions, the file is not executable and
606 set-user-ID mode is set.
607 If in the group permissions, the file is not executable
608 and set-group-ID mode is set.
610 If in the owner permissions, the file is executable
611 and set-user-ID mode is set.
612 If in the group permissions, the file is executable
613 and setgroup-ID mode is set.
615 The file is executable or the directory is
618 The file is neither readable, writable, executable,
619 nor set-user-ID nor set-group-ID mode, nor sticky.
623 These next two apply only to the third character in the last group
625 .Bl -tag -width 4n -offset indent
627 The sticky bit is set
630 but not execute or search permission.
636 The sticky bit is set (mode
638 and is searchable or executable.
646 The next field contains a
649 character if the file has an ACL, or a
655 utility does not show the actual ACL;
660 The following environment variables affect the execution of
662 .Bl -tag -width ".Ev CLICOLOR_FORCE"
664 If this is set, its value, rounded up to 512 or down to a
665 multiple of 512, will be used as the block size in bytes by the
672 subsection for more information.
676 color sequences to distinguish file types.
680 In addition to the file types mentioned in the
682 option some extra attributes (setuid bit set, etc.) are also displayed.
683 The colorization is dependent on a terminal type with the proper
688 console has the proper capabilities,
689 but to display the colors in an
690 .Xr xterm 1 Pq Pa ports/x11/xterm ,
694 variable must be set to
696 Other terminal types may require similar adjustments.
698 is silently disabled if the output is not directed to a terminal
701 variable is defined or
705 .It Ev CLICOLOR_FORCE
706 Color sequences are normally disabled if the output is not directed to
708 This can be overridden by setting this variable.
711 variable still needs to reference a color capable terminal however
712 otherwise it is not possible to determine which color sequences to
719 If this variable contains a string representing a
720 decimal integer, it is used as the
721 column position width for displaying
722 multiple-text-column output.
725 utility calculates how
726 many pathname text columns to display
727 based on the width provided.
733 The locale to use when determining the order of day and month in the long
738 for more information.
740 The value of this variable describes what color to use for which
741 attribute when colors are enabled with
745 This string is a concatenation of pairs of the format
749 is the foreground color and
751 is the background color.
752 When the background color is capitalized, the text will underlined.
754 The color designators are as follows:
756 .Bl -tag -width 4n -offset indent -compact
774 bold or underlined black, usually shows up as dark grey
776 bold or underlined red
778 bold or underlined green
780 bold or underlined brown, usually shows up as yellow
782 bold or underlined blue
784 bold or underlined magenta
786 bold or underlined cyan
788 bold or underlined light grey; looks like bright white
790 default foreground or background
792 default foreground or background, with an underline or bold
795 Note that the above are standard
798 The actual display may differ
799 depending on the color capabilities of the terminal in use.
801 The order of the attributes are as follows:
803 .Bl -enum -offset indent -compact
819 executable with setuid bit set
821 executable with setgid bit set
823 directory writable to others, with sticky bit
825 directory writable to others, without sticky bit
829 .Qq "exfxcxdxbxegedabagacad" ,
830 i.e., blue foreground and
831 default background for regular directories, black foreground and red
832 background for setuid executables, etc.
834 If this variable is set, it is considered to be a
835 colon-delimited list of minimum column widths.
837 and insufficient widths are ignored (thus zero signifies
838 a dynamically sized column).
839 Not all columns have changeable widths.
841 in order: inode, block count, number of links, user name,
842 group name, flags, file size, file name.
844 If this variable is set, the
846 option sorts the names of files with the same modification timestamp in the same
847 sense as the time sort.
848 See the description of the
850 option for more details.
856 functionality depends on a terminal type with color capabilities.
858 The timezone to use when displaying dates.
861 for more information.
866 List the contents of the current working directory in long format:
870 In addition to listing the contents of the current working directory in
871 long format, show inode numbers, file flags (see
873 and suffix each filename with a symbol representing its file type:
879 sorting the output such that the mostly recently modified entries are
882 .Dl $ ls -lt /var/log
884 The group field is now automatically included in the long listing for
885 files in order to be compatible with the
893 .Xr xterm 1 Pq Pa ports/x11/xterm ,
905 With the exception of options
916 .Fl B , D , G , I , T , U , W , Z , b , h , v , w , y
919 are non-standard extensions.
921 The ACL support is compatible with
924 .Pq Dq Tn POSIX Ns .2c
938 To maintain backward compatibility, the relationships between the many
939 options are quite complex.
941 The exception mentioned in the
943 option description might be a feature that was
944 based on the fact that single-column output
945 usually goes to something other than a terminal.
946 It is debatable whether this is a design bug.
949 mandates opposite sort orders for files with the same timestamp when