]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - bin/ls/ls.1
This commit was generated by cvs2svn to compensate for changes in r156283,
[FreeBSD/FreeBSD.git] / bin / ls / ls.1
1 .\"-
2 .\" Copyright (c) 1980, 1990, 1991, 1993, 1994
3 .\"     The Regents of the University of California.  All rights reserved.
4 .\"
5 .\" This code is derived from software contributed to Berkeley by
6 .\" the Institute of Electrical and Electronics Engineers, Inc.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
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.
19 .\"
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
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)ls.1        8.7 (Berkeley) 7/29/94
33 .\" $FreeBSD$
34 .\"
35 .Dd November 16, 2005
36 .Dt LS 1
37 .Os
38 .Sh NAME
39 .Nm ls
40 .Nd list directory contents
41 .Sh SYNOPSIS
42 .Nm
43 .Op Fl ABCFGHILPRSTWZabcdfghiklmnopqrstuwx1
44 .Op Ar
45 .Sh DESCRIPTION
46 For each operand that names a
47 .Ar file
48 of a type other than
49 directory,
50 .Nm
51 displays its name as well as any requested,
52 associated information.
53 For each operand that names a
54 .Ar file
55 of type directory,
56 .Nm
57 displays the names of files contained
58 within that directory, as well as any requested, associated
59 information.
60 .Pp
61 If no operands are given, the contents of the current
62 directory are displayed.
63 If more than one operand is given,
64 non-directory operands are displayed first; directory
65 and non-directory operands are sorted separately and in
66 lexicographical order.
67 .Pp
68 The following options are available:
69 .Bl -tag -width indent
70 .It Fl A
71 List all entries except for
72 .Pa \&.
73 and
74 .Pa .. .
75 Automatically set for the super-user unless
76 .Fl I
77 is specified.
78 .It Fl B
79 Force printing of non-printable characters (as defined by
80 .Xr ctype 3
81 and current locale settings) in file names as
82 .Li \e Ns Va xxx ,
83 where
84 .Va xxx
85 is the numeric value of the character in octal.
86 .It Fl C
87 Force multi-column output; this is the default when output is to a terminal.
88 .It Fl F
89 Display a slash
90 .Pq Ql /
91 immediately after each pathname that is a directory,
92 an asterisk
93 .Pq Ql *
94 after each that is executable,
95 an at sign
96 .Pq Ql @
97 after each symbolic link,
98 an equals sign
99 .Pq Ql =
100 after each socket,
101 a percent sign
102 .Pq Ql %
103 after each whiteout,
104 and a vertical bar
105 .Pq Ql \&|
106 after each that is a
107 .Tn FIFO .
108 .It Fl G
109 Enable colorized output.
110 This option is equivalent to defining
111 .Ev CLICOLOR
112 in the environment.
113 (See below.)
114 .It Fl H
115 Symbolic links on the command line are followed.
116 This option is assumed if
117 none of the
118 .Fl F , d ,
119 or
120 .Fl l
121 options are specified.
122 .It Fl I
123 Prevent
124 .Fl A
125 from being automatically set for the super-user.
126 .It Fl L
127 If argument is a symbolic link, list the file or directory the link references
128 rather than the link itself.
129 This option cancels the
130 .Fl P
131 option.
132 .It Fl P
133 If argument is a symbolic link, list the link itself rather than the
134 object the link references.
135 This option cancels the
136 .Fl H
137 and
138 .Fl L
139 options.
140 .It Fl R
141 Recursively list subdirectories encountered.
142 .It Fl S
143 Sort by size (largest file first) before sorting the operands in
144 lexicographical order.
145 .It Fl T
146 When used with the
147 .Fl l
148 (lowercase letter
149 .Dq ell )
150 option, display complete time information for the file, including
151 month, day, hour, minute, second, and year.
152 .It Fl W
153 Display whiteouts when scanning directories.
154 .It Fl Z
155 Display each file's MAC label; see
156 .Xr maclabel 7 .
157 .It Fl a
158 Include directory entries whose names begin with a
159 dot
160 .Pq Pa \&. .
161 .It Fl b
162 As
163 .Fl B ,
164 but use
165 .Tn C
166 escape codes whenever possible.
167 .It Fl c
168 Use time when file status was last changed for sorting or printing.
169 .It Fl d
170 Directories are listed as plain files (not searched recursively).
171 .It Fl f
172 Output is not sorted.
173 .It Fl g
174 This option is deprecated and is only available for compatibility
175 with
176 .Bx 4.3 ;
177 it was used to display the group name in the long
178 .Pq Fl l
179 format output.
180 .It Fl h
181 When used with the
182 .Fl l
183 option, use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte
184 and Petabyte in order to reduce the number of digits to four or fewer
185 using base 2 for sizes.
186 .It Fl i
187 For each file, print the file's file serial number (inode number).
188 .It Fl k
189 This has the same effect as setting environment variable
190 .Ev BLOCKSIZE
191 to 1024, except that it also nullifies any
192 .Fl h
193 options to its left.
194 .It Fl l
195 (The lowercase letter
196 .Dq ell . )
197 List files in the long format, as described in the
198 .Sx The Long Format
199 subsection below.
200 .It Fl m
201 Stream output format; list files across the page, separated by commas.
202 .It Fl n
203 Display user and group IDs numerically rather than converting to a user
204 or group name in a long
205 .Pq Fl l
206 output.
207 .It Fl o
208 Include the file flags in a long
209 .Pq Fl l
210 output.
211 .It Fl p
212 Write a slash
213 .Pq Ql /
214 after each filename if that file is a directory.
215 .It Fl q
216 Force printing of non-graphic characters in file names as
217 the character
218 .Ql \&? ;
219 this is the default when output is to a terminal.
220 .It Fl r
221 Reverse the order of the sort.
222 .It Fl s
223 Display the number of blocks used in the file system by each file.
224 Block sizes and directory totals are handled as described in
225 .Sx The Long Format
226 subsection below, except (if the long format is not also requested)
227 the directory totals are not output when the output is in a
228 single column, even if multi-column output is requested.
229 .It Fl t
230 Sort by time modified (most recently modified
231 first) before sorting the operands in lexicographical
232 order.
233 .It Fl u
234 Use time of last access,
235 instead of last modification
236 of the file for sorting
237 .Pq Fl t
238 or printing
239 .Pq Fl l .
240 .It Fl w
241 Force raw printing of non-printable characters.
242 This is the default
243 when output is not to a terminal.
244 .It Fl x
245 The same as
246 .Fl C ,
247 except that the multi-column output is produced with entries sorted
248 across, rather than down, the columns.
249 .It Fl 1
250 (The numeric digit
251 .Dq one . )
252 Force output to be
253 one entry per line.
254 This is the default when
255 output is not to a terminal.
256 .El
257 .Pp
258 The
259 .Fl 1 , C , x ,
260 and
261 .Fl l
262 options all override each other; the last one specified determines
263 the format used.
264 .Pp
265 The
266 .Fl c
267 and
268 .Fl u
269 options override each other; the last one specified determines
270 the file time used.
271 .Pp
272 The
273 .Fl B , b , w ,
274 and
275 .Fl q
276 options all override each other; the last one specified determines
277 the format used for non-printable characters.
278 .Pp
279 The
280 .Fl H , L
281 and
282 .Fl P
283 options all override each other (either partially or fully); they
284 are applied in the order specified.
285 .Pp
286 By default,
287 .Nm
288 lists one entry per line to standard
289 output; the exceptions are to terminals or when the
290 .Fl C
291 or
292 .Fl x
293 options are specified.
294 .Pp
295 File information is displayed with one or more
296 .Ao blank Ac Ns s
297 separating the information associated with the
298 .Fl i , s ,
299 and
300 .Fl l
301 options.
302 .Ss The Long Format
303 If the
304 .Fl l
305 option is given, the following information
306 is displayed for each file:
307 file mode,
308 number of links, owner name, group name,
309 MAC label,
310 number of bytes in the file, abbreviated
311 month, day-of-month file was last modified,
312 hour file last modified, minute file last
313 modified, and the pathname.
314 .Pp
315 If the modification time of the file is more than 6 months
316 in the past or future, then the year of the last modification
317 is displayed in place of the hour and minute fields.
318 .Pp
319 If the owner or group names are not a known user or group name,
320 or the
321 .Fl n
322 option is given,
323 the numeric ID's are displayed.
324 .Pp
325 If the file is a character special or block special file,
326 the major and minor device numbers for the file are displayed
327 in the size field.
328 If the file is a symbolic link the pathname of the
329 linked-to file is preceded by
330 .Dq Li -> .
331 .Pp
332 The listing of a directory's contents is preceded
333 by a labeled total number of blocks used in the file system by the files
334 which are listed as the directory's contents
335 (which may or may not include
336 .Pa \&.
337 and
338 .Pa ..
339 and other files which start with a dot, depending on other options).
340 .Pp
341 The default block size is 512 bytes.
342 The block size may be set with option
343 .Fl k
344 or environment variable
345 .Ev BLOCKSIZE .
346 Numbers of blocks in the output will have been rounded up so the
347 numbers of bytes is at least as many as used by the corresponding
348 file system blocks (which might have a different size).
349 .Pp
350 The file mode printed under the
351 .Fl l
352 option consists of the
353 entry type and the permissions.
354 The entry type character describes the type of file, as
355 follows:
356 .Pp
357 .Bl -tag -width 4n -offset indent -compact
358 .It Sy b
359 Block special file.
360 .It Sy c
361 Character special file.
362 .It Sy d
363 Directory.
364 .It Sy l
365 Symbolic link.
366 .It Sy s
367 Socket link.
368 .It Sy p
369 .Tn FIFO .
370 .It Sy \-
371 Regular file.
372 .El
373 .Pp
374 The next three fields
375 are three characters each:
376 owner permissions,
377 group permissions, and
378 other permissions.
379 Each field has three character positions:
380 .Bl -enum -offset indent
381 .It
382 If
383 .Sy r ,
384 the file is readable; if
385 .Sy \- ,
386 it is not readable.
387 .It
388 If
389 .Sy w ,
390 the file is writable; if
391 .Sy \- ,
392 it is not writable.
393 .It
394 The first of the following that applies:
395 .Bl -tag -width 4n -offset indent
396 .It Sy S
397 If in the owner permissions, the file is not executable and
398 set-user-ID mode is set.
399 If in the group permissions, the file is not executable
400 and set-group-ID mode is set.
401 .It Sy s
402 If in the owner permissions, the file is executable
403 and set-user-ID mode is set.
404 If in the group permissions, the file is executable
405 and setgroup-ID mode is set.
406 .It Sy x
407 The file is executable or the directory is
408 searchable.
409 .It Sy \-
410 The file is neither readable, writable, executable,
411 nor set-user-ID nor set-group-ID mode, nor sticky.
412 (See below.)
413 .El
414 .Pp
415 These next two apply only to the third character in the last group
416 (other permissions).
417 .Bl -tag -width 4n -offset indent
418 .It Sy T
419 The sticky bit is set
420 (mode
421 .Li 1000 ) ,
422 but not execute or search permission.
423 (See
424 .Xr chmod 1
425 or
426 .Xr sticky 8 . )
427 .It Sy t
428 The sticky bit is set (mode
429 .Li 1000 ) ,
430 and is searchable or executable.
431 (See
432 .Xr chmod 1
433 or
434 .Xr sticky 8 . )
435 .El
436 .El
437 .Pp
438 The next field contains a
439 plus
440 .Pq Ql +
441 character if the file has an ACL, or a
442 space
443 .Pq Ql " "
444 if it does not.
445 The
446 .Nm
447 utility does not show the actual ACL;
448 use
449 .Xr getfacl 1
450 to do this.
451 .Sh ENVIRONMENT
452 The following environment variables affect the execution of
453 .Nm :
454 .Bl -tag -width ".Ev CLICOLOR_FORCE"
455 .It Ev BLOCKSIZE
456 If this is set, its value, rounded up to 512 or down to a
457 multiple of 512, will be used as the block size in bytes by the
458 .Fl l
459 and
460 .Fl s
461 options.
462 See
463 .Sx The Long Format
464 subsection for more information.
465 .It Ev CLICOLOR
466 Use
467 .Tn ANSI
468 color sequences to distinguish file types.
469 See
470 .Ev LSCOLORS
471 below.
472 In addition to the file types mentioned in the
473 .Fl F
474 option some extra attributes (setuid bit set, etc.) are also displayed.
475 The colorization is dependent on a terminal type with the proper
476 .Xr termcap 5
477 capabilities.
478 The default
479 .Dq Li cons25
480 console has the proper capabilities,
481 but to display the colors in an
482 .Xr xterm 1 ,
483 for example,
484 the
485 .Ev TERM
486 variable must be set to
487 .Dq Li xterm-color .
488 Other terminal types may require similar adjustments.
489 Colorization
490 is silently disabled if the output is not directed to a terminal
491 unless the
492 .Ev CLICOLOR_FORCE
493 variable is defined.
494 .It Ev CLICOLOR_FORCE
495 Color sequences are normally disabled if the output is not directed to
496 a terminal.
497 This can be overridden by setting this flag.
498 The
499 .Ev TERM
500 variable still needs to reference a color capable terminal however
501 otherwise it is not possible to determine which color sequences to
502 use.
503 .It Ev COLUMNS
504 If this variable contains a string representing a
505 decimal integer, it is used as the
506 column position width for displaying
507 multiple-text-column output.
508 The
509 .Nm
510 utility calculates how
511 many pathname text columns to display
512 based on the width provided.
513 (See
514 .Fl C
515 and
516 .Fl x . )
517 .It Ev LANG
518 The locale to use when determining the order of day and month in the long
519 .Fl l
520 format output.
521 See
522 .Xr environ 7
523 for more information.
524 .It Ev LSCOLORS
525 The value of this variable describes what color to use for which
526 attribute when colors are enabled with
527 .Ev CLICOLOR .
528 This string is a concatenation of pairs of the format
529 .Ar f Ns Ar b ,
530 where
531 .Ar f
532 is the foreground color and
533 .Ar b
534 is the background color.
535 .Pp
536 The color designators are as follows:
537 .Pp
538 .Bl -tag -width 4n -offset indent -compact
539 .It Sy a
540 black
541 .It Sy b
542 red
543 .It Sy c
544 green
545 .It Sy d
546 brown
547 .It Sy e
548 blue
549 .It Sy f
550 magenta
551 .It Sy g
552 cyan
553 .It Sy h
554 light grey
555 .It Sy A
556 bold black, usually shows up as dark grey
557 .It Sy B
558 bold red
559 .It Sy C
560 bold green
561 .It Sy D
562 bold brown, usually shows up as yellow
563 .It Sy E
564 bold blue
565 .It Sy F
566 bold magenta
567 .It Sy G
568 bold cyan
569 .It Sy H
570 bold light grey; looks like bright white
571 .It Sy x
572 default foreground or background
573 .El
574 .Pp
575 Note that the above are standard
576 .Tn ANSI
577 colors.
578 The actual display may differ
579 depending on the color capabilities of the terminal in use.
580 .Pp
581 The order of the attributes are as follows:
582 .Pp
583 .Bl -enum -offset indent -compact
584 .It
585 directory
586 .It
587 symbolic link
588 .It
589 socket
590 .It
591 pipe
592 .It
593 executable
594 .It
595 block special
596 .It
597 character special
598 .It
599 executable with setuid bit set
600 .It
601 executable with setgid bit set
602 .It
603 directory writable to others, with sticky bit
604 .It
605 directory writable to others, without sticky bit
606 .El
607 .Pp
608 The default is
609 .Qq "exfxcxdxbxegedabagacad" ,
610 i.e., blue foreground and
611 default background for regular directories, black foreground and red
612 background for setuid executables, etc.
613 .It Ev LS_COLWIDTHS
614 If this variable is set, it is considered to be a
615 colon-delimited list of minimum column widths.
616 Unreasonable
617 and insufficient widths are ignored (thus zero signifies
618 a dynamically sized column).
619 Not all columns have changeable widths.
620 The fields are,
621 in order: inode, block count, number of links, user name,
622 group name, flags, file size, file name.
623 .It Ev TERM
624 The
625 .Ev CLICOLOR
626 functionality depends on a terminal type with color capabilities.
627 .It Ev TZ
628 The timezone to use when displaying dates.
629 See
630 .Xr environ 7
631 for more information.
632 .El
633 .Sh EXIT STATUS
634 .Ex -std
635 .Sh COMPATIBILITY
636 The group field is now automatically included in the long listing for
637 files in order to be compatible with the
638 .St -p1003.2
639 specification.
640 .Sh SEE ALSO
641 .Xr chflags 1 ,
642 .Xr chmod 1 ,
643 .Xr getfacl 1 ,
644 .Xr sort 1 ,
645 .Xr xterm 1 ,
646 .Xr termcap 5 ,
647 .Xr maclabel 7 ,
648 .Xr symlink 7 ,
649 .Xr getfmac 8 ,
650 .Xr sticky 8
651 .Sh STANDARDS
652 With the exception of options
653 .Fl I , g , n
654 and
655 .Fl o ,
656 the
657 .Nm
658 utility conforms to
659 .St -p1003.1-2001 .
660 .Pp
661 The ACL support is compatible with
662 .Tn IEEE
663 Std\~1003.2c
664 .Pq Dq Tn POSIX Ns .2c
665 Draft\~17
666 (withdrawn).
667 .Sh HISTORY
668 An
669 .Nm
670 command appeared in
671 .At v1 .
672 .Sh BUGS
673 To maintain backward compatibility, the relationships between the many
674 options are quite complex.
675 .Pp
676 The exception mentioned in the
677 .Fl s
678 option description might be a feature that was
679 based on the fact that single-column output
680 usually goes to something other than a terminal.
681 It is debatable whether this is a design bug.