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 .\" 3. All advertising materials mentioning features or use of this software
16 .\" must display the following acknowledgment:
17 .\" This product includes software developed by the University of
18 .\" California, Berkeley and its contributors.
19 .\" 4. Neither the name of the University nor the names of its contributors
20 .\" may be used to endorse or promote products derived from this software
21 .\" without specific prior written permission.
23 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 .\" @(#)ls.1 8.7 (Berkeley) 7/29/94
36 .\" $FreeBSD: src/bin/ls/ls.1,v 1.33.2.21 2003/05/07 23:56:14 trhodes Exp $
37 .\" $DragonFly: src/bin/ls/ls.1,v 1.2 2003/06/17 04:22:50 dillon Exp $
44 .Nd list directory contents
47 .Op Fl ABCFGHLPRTWabcdfghiklmnopqrstuwx1
50 For each operand that names a
55 displays its name as well as any requested,
56 associated information.
57 For each operand that names a
61 displays the names of files contained
62 within that directory, as well as any requested, associated
65 If no operands are given, the contents of the current
66 directory are displayed.
67 If more than one operand is given,
68 non-directory operands are displayed first; directory
69 and non-directory operands are sorted separately and in
70 lexicographical order.
72 The following options are available:
73 .Bl -tag -width indent
75 List all entries except for
79 Always set for the super-user.
81 Force printing of non-printable characters (as defined by
83 and current locale settings) in file names as
87 is the numeric value of the character in octal.
89 Force multi-column output; this is the default when output is to a terminal.
93 immediately after each pathname that is a directory,
96 after each that is executable,
99 after each symbolic link,
111 Enable colorized output.
112 This option is equivalent to defining
117 Symbolic links on the command line are followed.
118 This option is assumed if
123 options are specified.
125 If argument is a symbolic link, list the file or directory the link references
126 rather than the link itself.
127 This option cancels the
131 If argument is a symbolic link, list the link itself rather than the
132 object the link references.
133 This option cancels the
139 Recursively list subdirectories encountered.
145 option, display complete time information for the file, including
146 month, day, hour, minute, second, and year.
148 Display whiteouts when scanning directories.
150 Include directory entries whose names begin with a
158 escape codes whenever possible.
160 Use time when file status was last changed for sorting or printing.
162 Directories are listed as plain files (not searched recursively).
164 Output is not sorted.
166 This option is deprecated and is only available for compatibility
169 it was used to display the group name in the long
175 option, use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte
176 and Petabyte in order to reduce the number of digits to four or fewer
177 using base 2 for sizes.
179 For each file, print the file's file serial number (inode number).
183 option is specified, print the file size allocation in kilobytes,
185 This option overrides the environment variable
188 (The lowercase letter
192 If the output is to a terminal, a total sum for all the file
193 sizes is output on a line before the long listing.
195 Stream output format; list files across the page, separated by commas.
197 Display user and group IDs numerically rather than converting to a user
198 or group name in a long
202 Include the file flags in a long
208 after each filename if that file is a directory.
210 Force printing of non-graphic characters in file names as
213 this is the default when output is to a terminal.
215 Reverse the order of the sort to get reverse
216 lexicographical order or the oldest entries first.
218 Display the number of file system blocks actually used by each file, in units
219 of 512 bytes, where partial units are rounded up to the next integer value.
220 If the output is to a terminal, a total sum for all the file
221 sizes is output on a line before the listing.
222 The environment variable
224 overrides the unit size of 512 bytes.
226 Sort by time modified (most recently modified
227 first) before sorting the operands by lexicographical
230 Use time of last access,
231 instead of last modification
232 of the file for sorting
237 Force raw printing of non-printable characters.
239 when output is not to a terminal.
243 except that the multi-column output is produced with entries sorted
244 across, rather than down, the columns.
250 This is the default when
251 output is not to a terminal.
258 options all override each other; the last one specified determines
265 options override each other; the last one specified determines
272 options all override each other; the last one specified determines
273 the format used for non-printable characters.
279 options all override each other (either partially or fully); they
280 are applied in the order specified.
284 lists one entry per line to standard
285 output; the exceptions are to terminals or when the
289 options are specified.
291 File information is displayed with one or more
293 separating the information associated with the
301 option is given, the following information
302 is displayed for each file:
304 number of links, owner name, group name,
305 number of bytes in the file, abbreviated
306 month, day-of-month file was last modified,
307 hour file last modified, minute file last
308 modified, and the pathname.
309 In addition, for each directory whose contents are displayed, the total
310 number of 512-byte blocks used by the files in the directory is displayed
311 on a line by itself immediately before the information for the files in the
314 If the modification time of the file is more than 6 months
315 in the past or future, then the year of the last modification
316 is displayed in place of the hour and minute fields.
318 If the owner or group names are not a known user or group name,
322 the numeric ID's are displayed.
324 If the file is a character special or block special file,
325 the major and minor device numbers for the file are displayed
327 If the file is a symbolic link the pathname of the
328 linked-to file is preceded by
331 The file mode printed under the
333 option consists of the
334 entry type, owner permissions, and group permissions.
335 The entry type character describes the type of file, as
338 .Bl -tag -width 4n -offset indent -compact
342 Character special file.
355 The next three fields
356 are three characters each:
358 group permissions, and
360 Each field has three character positions:
361 .Bl -enum -offset indent
365 the file is readable; if
371 the file is writable; if
375 The first of the following that applies:
376 .Bl -tag -width 4n -offset indent
378 If in the owner permissions, the file is not executable and
379 set-user-ID mode is set.
380 If in the group permissions, the file is not executable
381 and set-group-ID mode is set.
383 If in the owner permissions, the file is executable
384 and set-user-ID mode is set.
385 If in the group permissions, the file is executable
386 and setgroup-ID mode is set.
388 The file is executable or the directory is
391 The file is neither readable, writable, executable,
392 nor set-user-ID nor set-group-ID mode, nor sticky.
396 These next two apply only to the third character in the last group
398 .Bl -tag -width 4n -offset indent
400 The sticky bit is set
403 but not execute or search permission.
409 The sticky bit is set (mode
411 and is searchable or executable.
419 The following is how to do an
421 listing sorted by size (and shows why
423 does not need a separate option for this):
425 .Dl "ls -l | sort -n +4"
432 to get the results sorted from largest to smallest (a reverse sort).
436 The following environment variables affect the execution of
438 .Bl -tag -width ".Ev CLICOLOR_FORCE"
440 If the environment variable
442 is set, the block counts
445 will be displayed in units of that size block.
449 color sequences to distinguish file types.
453 In addition to the file types mentioned in the
455 option some extra attributes (setuid bit set, etc.) are also displayed.
456 The colorization is dependent on a terminal type with the proper
461 console has the proper capabilities,
462 but to display the colors in an
467 variable must be set to
469 Other terminal types may require similar adjustments.
471 is silently disabled if the output isn't directed to a terminal
475 .It Ev CLICOLOR_FORCE
476 Color sequences are normally disabled if the output isn't directed to
478 This can be overridden by setting this flag.
481 variable still needs to reference a color capable terminal however
482 otherwise it is not possible to determine which color sequences to
485 If this variable contains a string representing a
486 decimal integer, it is used as the
487 column position width for displaying
488 multiple-text-column output.
491 utility calculates how
492 many pathname text columns to display
493 based on the width provided.
499 The locale to use when determining the order of day and month in the long
504 for more information.
506 The value of this variable describes what color to use for which
507 attribute when colors are enabled with
509 This string is a concatenation of pairs of the format
513 is the foreground color and
515 is the background color.
517 The color designators are as follows:
519 .Bl -tag -width 4n -offset indent -compact
537 bold black, usually shows up as dark grey
543 bold brown, usually shows up as yellow
551 bold light grey; looks like bright white
553 default foreground or background
556 Note that the above are standard
559 The actual display may differ
560 depending on the color capabilities of the terminal in use.
562 The order of the attributes are as follows:
564 .Bl -enum -offset indent -compact
580 executable with setuid bit set
582 executable with setgid bit set
584 directory writable to others, with sticky bit
586 directory writable to others, without sticky bit
590 .Qq "exfxcxdxbxegedabagacad" ,
591 i.e. blue foreground and
592 default background for regular directories, black foreground and red
593 background for setuid executables, etc.
595 If this variable is set, it is considered to be a
596 colon-delimited list of minimum column widths.
598 and insufficient widths are ignored (thus zero signifies
599 a dynamically sized column).
600 Not all columns have changeable widths.
602 in order: inode, block count, number of links, user name,
603 group name, flags, file size, file name.
607 functionality depends on a terminal type with color capabilities.
609 The timezone to use when displaying dates.
612 for more information.
615 The group field is now automatically included in the long listing for
616 files in order to be compatible with the
638 To maintain backward compatibility, the relationships between the many
639 options are quite complex.