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 .\" 4. 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
44 .Op Fl ABCFGHILPRSTUWZabcdfghiklmnopqrstuwxy1,
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
75 in a selection of different human and machine readable formats.
78 for details on command line arguments.
80 Include directory entries whose names begin with a
87 Automatically set for the super-user unless
91 Force printing of non-printable characters (as defined by
93 and current locale settings) in file names as
97 is the numeric value of the character in octal.
98 This option is not defined in
101 Force multi-column output; this is the default when output is to a terminal.
103 When printing in the long
107 to format the date and time output.
112 Depending on the choice of format string, this may result in a
113 different number of columns in the output.
114 This option overrides the
117 This option is not defined in
122 immediately after each pathname that is a directory,
125 after each that is executable,
128 after each symbolic link,
140 Enable colorized output.
141 This option is equivalent to defining
145 This functionality can be compiled out by removing the definition of
147 This option is not defined in
150 Symbolic links on the command line are followed.
151 This option is assumed if
156 options are specified.
160 from being automatically set for the super-user.
161 This option is not defined in
164 If argument is a symbolic link, list the file or directory the link references
165 rather than the link itself.
166 This option cancels the
170 If argument is a symbolic link, list the link itself rather than the
171 object the link references.
172 This option cancels the
178 Recursively list subdirectories encountered.
180 Sort by size (largest file first) before sorting the operands in
181 lexicographical order.
183 When printing in the long
185 format, display complete time information for the file, including
186 month, day, hour, minute, second, and year.
189 option gives even more control over the output format.
190 This option is not defined in
193 Use time when file was created for sorting or printing.
194 This option is not defined in
197 Display whiteouts when scanning directories.
198 This option is not defined in
201 Display each file's MAC label; see
203 This option is not defined in
206 Include directory entries whose names begin with a
214 escape codes whenever possible.
215 This option is not defined in
218 Use time when file status was last changed for sorting or printing.
220 Directories are listed as plain files (not searched recursively).
222 Output is not sorted.
225 It also negates the effect of the
233 this option has no effect on the
241 This option has no effect.
242 It is only available for compatibility with
244 where it was used to display the group name in the long
247 This option is incompatible with
252 option, use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte
253 and Petabyte in order to reduce the number of digits to four or fewer
254 using base 2 for sizes.
255 This option is not defined in
258 For each file, print the file's file serial number (inode number).
260 This has the same effect as setting environment variable
262 to 1024, except that it also nullifies any
266 (The lowercase letter
268 List files in the long format, as described in the
272 Stream output format; list files across the page, separated by commas.
274 Display user and group IDs numerically rather than converting to a user
275 or group name in a long
279 Include the file flags in a long
282 This option is incompatible with
286 for a list of file flags and their meanings.
290 after each filename if that file is a directory.
292 Force printing of non-graphic characters in file names as
295 this is the default when output is to a terminal.
297 Reverse the order of the sort.
299 Display the number of blocks used in the file system by each file.
300 Block sizes and directory totals are handled as described in
302 subsection below, except (if the long format is not also requested)
303 the directory totals are not output when the output is in a
304 single column, even if multi-column output is requested.
306 Sort by descending time modified (most recently modified first).
307 If two files have the same modification timestamp, sort their names
308 in ascending lexicographical order.
311 option reverses both of these sort orders.
313 Note that these sort orders are contradictory: the time sequence is in
314 descending order, the lexicographical sort is in ascending order.
315 This behavior is mandated by
317 This feature can cause problems listing files stored with sequential names on
318 FAT file systems, such as from digital cameras, where it is possible to have
319 more than one image with the same timestamp.
320 In such a case, the photos cannot be listed in the sequence in which
322 To ensure the same sort order for time and for lexicographical sorting, set the
330 to reverse the lexicographical sort order when sorting files with the
331 same modification timestamp.
333 Use time of last access,
334 instead of time of last modification
335 of the file for sorting
340 Force raw printing of non-printable characters.
342 when output is not to a terminal.
343 This option is not defined in
348 except that the multi-column output is produced with entries sorted
349 across, rather than down, the columns.
353 option is set, sort the alphabetical output in the same order as the time output.
354 This has the same effect as setting
356 See the description of the
358 option for more details.
359 This option is not defined in
366 This is the default when
367 output is not to a terminal.
371 option is set, print file sizes grouped and separated by thousands using the
372 non-monetary separator returned by
374 typically a comma or period.
375 If no locale is set, or the locale does not have a non-monetary separator, this
376 option has no effect.
377 This option is not defined in
385 options all override each other; the last one specified determines
392 options all override each other; the last one specified determines
399 options override each other; the last one specified determines
406 options all override each other; the last one specified determines
407 the format used for non-printable characters.
413 options all override each other (either partially or fully); they
414 are applied in the order specified.
418 lists one entry per line to standard
419 output; the exceptions are to terminals or when the
423 options are specified.
425 File information is displayed with one or more
427 separating the information associated with the
435 option is given, the following information
436 is displayed for each file:
438 number of links, owner name, group name,
440 number of bytes in the file, abbreviated
441 month, day-of-month file was last modified,
442 hour file last modified, minute file last
443 modified, and the pathname.
445 If the modification time of the file is more than 6 months
446 in the past or future, and the
451 then the year of the last modification
452 is displayed in place of the hour and minute fields.
454 If the owner or group names are not a known user or group name,
458 the numeric ID's are displayed.
460 If the file is a character special or block special file,
461 the device number for the file is displayed in the size field.
462 If the file is a symbolic link the pathname of the
463 linked-to file is preceded by
466 The listing of a directory's contents is preceded
467 by a labeled total number of blocks used in the file system by the files
468 which are listed as the directory's contents
469 (which may or may not include
473 and other files which start with a dot, depending on other options).
475 The default block size is 512 bytes.
476 The block size may be set with option
478 or environment variable
480 Numbers of blocks in the output will have been rounded up so the
481 numbers of bytes is at least as many as used by the corresponding
482 file system blocks (which might have a different size).
484 The file mode printed under the
486 option consists of the
487 entry type and the permissions.
488 The entry type character describes the type of file, as
491 .Bl -tag -width 4n -offset indent -compact
497 Character special file.
510 The next three fields
511 are three characters each:
513 group permissions, and
515 Each field has three character positions:
516 .Bl -enum -offset indent
520 the file is readable; if
526 the file is writable; if
530 The first of the following that applies:
531 .Bl -tag -width 4n -offset indent
533 If in the owner permissions, the file is not executable and
534 set-user-ID mode is set.
535 If in the group permissions, the file is not executable
536 and set-group-ID mode is set.
538 If in the owner permissions, the file is executable
539 and set-user-ID mode is set.
540 If in the group permissions, the file is executable
541 and setgroup-ID mode is set.
543 The file is executable or the directory is
546 The file is neither readable, writable, executable,
547 nor set-user-ID nor set-group-ID mode, nor sticky.
551 These next two apply only to the third character in the last group
553 .Bl -tag -width 4n -offset indent
555 The sticky bit is set
558 but not execute or search permission.
564 The sticky bit is set (mode
566 and is searchable or executable.
574 The next field contains a
577 character if the file has an ACL, or a
583 utility does not show the actual ACL;
588 The following environment variables affect the execution of
590 .Bl -tag -width ".Ev CLICOLOR_FORCE"
592 If this is set, its value, rounded up to 512 or down to a
593 multiple of 512, will be used as the block size in bytes by the
600 subsection for more information.
604 color sequences to distinguish file types.
608 In addition to the file types mentioned in the
610 option some extra attributes (setuid bit set, etc.) are also displayed.
611 The colorization is dependent on a terminal type with the proper
616 console has the proper capabilities,
617 but to display the colors in an
622 variable must be set to
624 Other terminal types may require similar adjustments.
626 is silently disabled if the output is not directed to a terminal
630 .It Ev CLICOLOR_FORCE
631 Color sequences are normally disabled if the output is not directed to
633 This can be overridden by setting this variable.
636 variable still needs to reference a color capable terminal however
637 otherwise it is not possible to determine which color sequences to
640 If this variable contains a string representing a
641 decimal integer, it is used as the
642 column position width for displaying
643 multiple-text-column output.
646 utility calculates how
647 many pathname text columns to display
648 based on the width provided.
654 The locale to use when determining the order of day and month in the long
659 for more information.
661 The value of this variable describes what color to use for which
662 attribute when colors are enabled with
664 This string is a concatenation of pairs of the format
668 is the foreground color and
670 is the background color.
672 The color designators are as follows:
674 .Bl -tag -width 4n -offset indent -compact
692 bold black, usually shows up as dark grey
698 bold brown, usually shows up as yellow
706 bold light grey; looks like bright white
708 default foreground or background
711 Note that the above are standard
714 The actual display may differ
715 depending on the color capabilities of the terminal in use.
717 The order of the attributes are as follows:
719 .Bl -enum -offset indent -compact
735 executable with setuid bit set
737 executable with setgid bit set
739 directory writable to others, with sticky bit
741 directory writable to others, without sticky bit
745 .Qq "exfxcxdxbxegedabagacad" ,
746 i.e., blue foreground and
747 default background for regular directories, black foreground and red
748 background for setuid executables, etc.
750 If this variable is set, it is considered to be a
751 colon-delimited list of minimum column widths.
753 and insufficient widths are ignored (thus zero signifies
754 a dynamically sized column).
755 Not all columns have changeable widths.
757 in order: inode, block count, number of links, user name,
758 group name, flags, file size, file name.
760 If this variable is set, the
762 option sorts the names of files with the same modification timestamp in the same
763 sense as the time sort.
764 See the description of the
766 option for more details.
770 functionality depends on a terminal type with color capabilities.
772 The timezone to use when displaying dates.
775 for more information.
780 List the contents of the current working directory in long format:
784 In addition to listing the contents of the current working directory in
785 long format, show inode numbers, file flags (see
787 and suffix each filename with a symbol representing its file type:
793 sorting the output such that the mostly recently modified entries are
796 .Dl $ ls -lt /var/log
798 The group field is now automatically included in the long listing for
799 files in order to be compatible with the
812 .Xr xo_parse_args 3 ,
819 With the exception of options
828 .Fl B , D , G , I , T , U , W , Z , b , h , w , y
831 are compatible extensions not defined in
834 The ACL support is compatible with
837 .Pq Dq Tn POSIX Ns .2c
846 To maintain backward compatibility, the relationships between the many
847 options are quite complex.
849 The exception mentioned in the
851 option description might be a feature that was
852 based on the fact that single-column output
853 usually goes to something other than a terminal.
854 It is debatable whether this is a design bug.
857 mandates opposite sort orders for files with the same timestamp when