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