1 LS(1) User Commands LS(1)
2
3
4
5 NAME
6 ls - list contents of directory
7
8 SYNOPSIS
9 /usr/bin/ls [-aAbcCdeEfFghHiklLmnopqrRsStuUwvVx1@]
10 [-/ c | v] [-% atime | crtime | ctime | mtime | all]
11 [--block-size size] [--color[=when]] [--file-type]
12 [--si] [--time-style style] [file]...
13
14
15 /usr/xpg4/bin/ls [-aAbcCdeEfFghHiklLmnopqrRsStuUwvVx1@]
16 [-/ c | v] [-% atime | crtime | ctime | mtime | all]
17 [--block-size size] [--color[=when]] [--file-type]
18 [--si] [--time-style style] [file]...
19
20
21 /usr/xpg6/bin/ls [-aAbcCdeEfFghHiklLmnopqrRsStuUwvVx1@]
22 [-/ c | v] [-% atime | crtime | ctime | mtime | all]
23 [--block-size size] [--color[=when]] [--file-type]
24 [--si] [--time-style style] [file]...
25
26
27 DESCRIPTION
28 For each file that is a directory, ls lists the contents of the
29 directory. For each file that is an ordinary file, ls repeats its name
30 and any other information requested. The output is sorted
31 alphabetically by default. When no argument is given, the current
32 directory (.) is listed. When several arguments are given, the
33 arguments are first sorted appropriately, but file arguments appear
34 before directories and their contents.
35
36
37 There are three major listing formats. The default format for output
38 directed to a terminal is multi-column with entries sorted down the
39 columns. The -1 option allows single column output and -m enables
40 stream output format. In order to determine output formats for the -C,
41 -x, and -m options, ls uses an environment variable, COLUMNS, to
42 determine the number of character positions available on one output
43 line. If this variable is not set, the terminfo(4) database is used to
44 determine the number of columns, based on the environment variable,
45 TERM. If this information cannot be obtained, 80 columns are assumed.
46 If the -w option is used, the argument overrides any other column
47 width.
48
49
50 The mode printed when the -e, -E, -g, -l, -n, -o, -v, -V, or -@ option
51 is in effect consists of eleven characters. The first character can be
52 one of the following:
53
54 d
55
56 The entry is a directory.
57
58
59 D
60
61 The entry is a door.
62
63
64 l
65
66 The entry is a symbolic link.
67
68
69 b
70
71 The entry is a block special file.
72
73
74 c
75
76 The entry is a character special file.
77
78
79 p
80
81 The entry is a FIFO (or "named pipe") special file.
82
83
84 P
85
86 The entry is an event port.
87
88
89 s
90
91 The entry is an AF_UNIX address family socket.
92
93
94 -
95
96 The entry is an ordinary file.
97
98
99
100 The next 9 characters are interpreted as three sets of three bits each.
101 The first set refers to the owner's permissions; the next to
102 permissions of others in the user-group of the file; and the last to
103 all others. Within each set, the three characters indicate permission
104 to read, to write, and to execute the file as a program, respectively.
105 For a directory, execute permission is interpreted to mean permission
106 to search the directory for a specified file. The character after
107 permissions is an ACL or extended attributes indicator. This character
108 is an @ if extended attributes are associated with the file and the -@
109 option is in effect. Otherwise, this character is a plus sign (+)
110 character if a non-trivial ACL is associated with the file or a space
111 character if not.
112
113
114 If -/ and/or -% are in effect, then the extended system attributes are
115 printed when filesystem supports extended system attributes. The
116 display looks as follows:
117
118 $ls -/ c file
119 -rw-r--r-- 1 root root 0 May 10 14:17 file
120 {AHRSadim-u--}
121
122 $ls -/ v file
123 -rw-r--r-- 1 root root 0 May 10 14:17 file
124 {archive,hidden,readonly,system,\
125 appendonly,nodump,immutable,av_modified,\
126 noav_quarantined,nounlink,nooffline,\
127 nosparse}
128
129 $ls -l -% all file
130 -rw-r--r-- 1 root root 0 May 10 14:17 file
131 timestamp: atime Jun 25 12:56:44 2007
132 timestamp: ctime May 10 14:20:23 2007
133 timestamp: mtime May 10 14:17:56 2007
134 timestamp: crtime May 10 14:17:56 2007
135
136
137
138
139 See the option descriptions of the -/ and -% option for details.
140
141
142 ls -l (the long list) prints its output as follows for the POSIX
143 locale:
144
145 -rwxrwxrwx+ 1 smith dev 10876 May 16 9:42 part2
146
147
148
149
150 Reading from right to left, you see that the current directory holds
151 one file, named part2. Next, the last time that file's contents were
152 modified was 9:42 A.M. on May 16. The file contains 10,876 characters,
153 or bytes. The owner of the file, or the user, belongs to the group dev
154 (perhaps indicating development), and his or her login name is smith.
155 The number, in this case 1, indicates the number of links to file part2
156 (see cp(1)). The plus sign indicates that there is an ACL associated
157 with the file. If the -@ option has been specified, the presence of
158 extended attributes supersede the presence of an ACL and the plus sign
159 is replaced with an 'at' sign (@). Finally, the dash and letters tell
160 you that user, group, and others have permissions to read, write, and
161 execute part2.
162
163
164 The execute (x) symbol occupies the third position of the three-
165 character sequence. A - in the third position would have indicated a
166 denial of execution permissions.
167
168
169 The permissions are indicated as follows:
170
171 r
172
173 The file is readable.
174
175
176 w
177
178 The file is writable.
179
180
181 x
182
183 The file is executable.
184
185
186 -
187
188 The indicated permission is not granted.
189
190
191 s
192
193 The set-user-ID or set-group-ID bit is on, and the corresponding
194 user or group execution bit is also on.
195
196
197 S
198
199 Undefined bit-state (the set-user-ID or set-group-id bit is on and
200 the user or group execution bit is off). For group permissions,
201 this applies only to non-regular files.
202
203
204 t
205
206 The 1000 (octal) bit, or sticky bit, is on (see chmod(1)), and
207 execution is on.
208
209
210 T
211
212 The 1000 bit is turned on, and execution is off (undefined bit-
213 state).
214
215
216 /usr/bin/ls
217 l
218
219 Mandatory locking occurs during access (on a regular file, the set-
220 group-ID bit is on and the group execution bit is off).
221
222
223 /usr/xpg4/bin/ls and /usr/xpg6/bin/ls
224 L
225
226 Mandatory locking occurs during access (on a regular file, the set-
227 group-ID bit is on and the group execution bit is off).
228
229
230
231 For user and group permissions, the third position is sometimes
232 occupied by a character other than x or -. s or S also can occupy this
233 position, referring to the state of the set-ID bit, whether it be the
234 user's or the group's. The ability to assume the same ID as the user
235 during execution is, for example, used during login when you begin as
236 root but need to assume the identity of the user you login as.
237
238
239 In the case of the sequence of group permissions, l can occupy the
240 third position. l refers to mandatory file and record locking. This
241 permission describes a file's ability to allow other files to lock its
242 reading or writing permissions during access.
243
244
245 For others permissions, the third position can be occupied by t or T.
246 These refer to the state of the sticky bit and execution permissions.
247
248 Color Output
249 If color output is enabled, the environment variable LS_COLORS is
250 checked. If it exists, it's contents are used to control the colors
251 used to display filenames. If it is not set, a default list of colors
252 is used. The format of LS_COLORS is a colon separated list of attribute
253 specifications. Each attribute specification is of the format
254
255 filespec=attr[;attr..]
256
257
258
259
260 filespec is either of the form *.SUFFIX, for example, *.jar or *.Z, or
261 one of the following file types:
262
263 no
264
265 Normal file
266
267
268 fi
269
270 Regular file
271
272
273 di
274
275 Directory
276
277
278 ln
279
280 Symbolic link
281
282
283 pi
284
285 FIFO or named pipe
286
287
288 so
289
290 Socket
291
292
293 do
294
295 Door file
296
297
298 bd
299
300 Block device
301
302
303 cd
304
305 Character device
306
307
308 ex
309
310 Execute bit (either user, group, or other) set
311
312
313 po
314
315 Event port
316
317
318 st
319
320 Sticky bit set
321
322
323 or
324
325 Orphaned symlink
326
327
328 sg
329
330 setgid binary
331
332
333 su
334
335 setuid binary
336
337
338 ow
339
340 world writable
341
342
343 tw
344
345 Sticky bit and world writable
346
347
348
349 attr is a semicolon delimited list of color and display attributes
350 which are combined to determine the final output color. Any combination
351 of attr values can be specified. Possible attr values are:
352
353 00
354
355 All attributes off (default terminal color)
356
357
358 01
359
360 Display text in bold
361
362
363 04
364
365 Display text with an underscore
366
367
368 05
369
370 Display text in bold
371
372
373 07
374
375 Display text with foreground and background colors reversed
376
377
378 08
379
380 Display using concealed text.
381
382
383
384 One of the following values can be chosen. If multiple values are
385 specified, the last specified value is used.
386
387 30
388
389 Set foreground to black.
390
391
392 31
393
394 Set foreground to red.
395
396
397 32
398
399 Set foreground to green.
400
401
402 33
403
404 Set foreground to yellow.
405
406
407 34
408
409 Set foreground to blue.
410
411
412 35
413
414 Set foreground to magenta (purple).
415
416 Set foreground to .
417
418
419 36
420
421 Set foreground to cyan.
422
423
424 37
425
426 Set foreground to white.
427
428
429 39
430
431 Set foreground to default terminal color.
432
433
434
435 One of the following can be specified. If multiple values are
436 specified, the last value specified is used.
437
438 40
439
440 Set foreground to black.
441
442
443 41
444
445 Set foreground to red.
446
447
448 42
449
450 Set foreground to green.
451
452
453 43
454
455 Set foreground to yellow.
456
457
458 44
459
460 Set foreground to blue.
461
462
463 45
464
465 Set foreground to magenta (purple).
466
467
468 46
469
470 Set foreground to cyan.
471
472
473 47
474
475 Set foreground to white.
476
477
478 49
479
480 Set foreground to default terminal color.
481
482
483
484 On some terminals, setting the bold attribute causes the foreground
485 colors to be high-intensity, that is, brighter. In such cases the low-
486 intensity yellow is often displayed as a brown or orange color.
487
488
489 At least one attribute must be listed for a file specification.
490
491
492 The appropriate color codes are chosen by selecting the most specific
493 match, starting with the file suffixes and proceeding with the file
494 types until a match is found. The no (normal file) type matches any
495 file.
496
497 OPTIONS
498 The following options are supported:
499
500 /usr/bin/ls, /usr/xpg4/bin/ls, and /usr/xpg6/bin/ls
501 The following options are supported for all three versions:
502
503 -a
504 --all
505
506 Lists all entries, including those that begin with a dot (.), which
507 are normally not listed.
508
509
510 -A
511 --almost-all
512
513 Lists all entries, including those that begin with a dot (.), with
514 the exception of the working directory (.) and the parent directory
515 (..).
516
517
518 -b
519 --escape
520
521 Forces printing of non-printable characters to be in the octal \ddd
522 notation.
523
524
525 -B
526 --ignore-backups
527
528 Do not display any files ending with a tilde (~).
529
530
531 -c
532
533 Uses time of last modification of the i-node (file created, mode
534 changed, and so forth) for sorting (-t) or printing (-l or -n).
535
536
537 -C
538
539 Multi-column output with entries sorted down the columns. This is
540 the default output format.
541
542
543 -d
544
545 If an argument is a directory, lists only its name (not its
546 contents). Often used with -l to get the status of a directory.
547
548
549 -e
550
551 The same as -l, except displays time to the second, and with one
552 format for all files regardless of age: mmm dd hh:mm:ss yyyy.
553
554
555 -E
556
557 The same as -l, except displays time to the nanosecond and with one
558 format for all files regardless of age: yyyy-mm-dd
559 hh:mm:ss.nnnnnnnnn (ISO 8601:2000 format).
560
561 In addition, this option displays the offset from UTC in ISO
562 8601:2000 standard format (+hhmm or -hhmm) or no characters if the
563 offset is indeterminable. The offset reflects the appropriate
564 standard or alternate offset in force at the file's displayed date
565 and time, under the current timezone.
566
567
568 -f
569
570 Forces each argument to be interpreted as a directory and list the
571 name found in each slot. This option turns off -l, -t, -s, -S, and
572 -r, and turns on -a. The order is the order in which entries appear
573 in the directory.
574
575
576 -F
577 --classify
578
579 Append a symbol after certain types of files to indicate the file
580 type. The following symbols are used:
581
582 /
583
584 Directory
585
586
587 >
588
589 Door file
590
591
592 |
593
594 Named pipe (FIFO)
595
596
597 @
598
599 Symbolic link
600
601
602 =
603
604 Socket
605
606
607 *
608
609 Executable
610
611
612
613 -g
614
615 The same as -l, except that the owner is not printed.
616
617
618 -h
619 --human-readable
620
621 All sizes are scaled to a human readable format, for example, 14K,
622 234M, 2.7G, or 3.0T. Scaling is done by repetitively dividing by
623 1024. The last --si or -h option determines the divisor used.
624
625
626 -H
627 --dereference-command-line
628
629 If an argument is a symbolic link that references a directory, this
630 option evaluates the file information and file type of the
631 directory that the link references, rather than those of the link
632 itself. However, the name of the link is displayed, rather than the
633 referenced directory.
634
635
636 -i
637 --inode
638
639 For each file, prints the i-node number in the first column of the
640 report.
641
642
643 -k
644
645 All sizes are printed in kbytes. Equivalent to --block-size=1024.
646
647
648 -l
649
650 Lists in long format, giving mode, ACL indication, number of links,
651 owner, group, size in bytes, and time of last modification for each
652 file (see above). If the file is a special file, the size field
653 instead contains the major and minor device numbers. If the time of
654 last modification is greater than six months ago, it is shown in
655 the format `month date year' for the POSIX locale. When the LC_TIME
656 locale category is not set to the POSIX locale, a different format
657 of the time field can be used. Files modified within six months
658 show `month date time'. If the file is a symbolic link, the
659 filename is printed followed by "->" and the path name of the
660 referenced file.
661
662
663 -L
664 --dereference
665
666 If an argument is a symbolic link, this option evaluates the file
667 information and file type of the file or directory that the link
668 references, rather than those of the link itself. However, the name
669 of the link is displayed, rather than the referenced file or
670 directory.
671
672
673 -m
674
675 Streams output format. Files are listed across the page, separated
676 by commas.
677
678
679 -n
680 --numeric-uid-gid
681
682 The same as -l, except that the owner's UID and group's GID numbers
683 are printed, rather than the associated character strings. Files
684 for which owner and/or group is a Windows Security Identifier
685 (SID), -n suppresses any lookups for the Windows Name string and
686 prints only the raw SID. Moreover, a second instance of this flag
687 (-nn) can be used to further suppress idmapd(1M) lookups of the
688 file's owner and/or group SID, thus forcing ls into printing the
689 raw ephemeral numeric identifiers.
690
691
692 -o
693 --no-group
694
695 The same as -l, except that the group is not printed.
696
697
698 -p
699
700 Puts a slash (/) after each filename if the file is a directory.
701
702
703 -q
704 --hide-control-chars
705
706 Forces printing of non-printable characters in file names as the
707 character question mark (?).
708
709
710 -r
711 --reverse
712
713 Reverses the order of sort to get reverse alphabetic, oldest first,
714 or smallest file size first as appropriate.
715
716
717 -R
718 --recursive
719
720 Recursively lists subdirectories encountered.
721
722
723 -s
724 --size
725
726 Indicate the total number of file system blocks consumed by each
727 file displayed.
728
729
730 -S
731
732 Sort by file size (in decreasing order) and for files with the same
733 size by file name (in increasing alphabetic order) instead of just
734 by name.
735
736
737 -t
738
739 Sorts by time stamp (latest first) instead of by name. The default
740 is the last modification time. See -c, -u and -%.
741
742
743 -u
744
745 Uses time of last access instead of last modification for sorting
746 (with the -t option) or printing (with the -l option).
747
748
749 -U
750
751 Output is unsorted.
752
753
754 -v
755
756 The same as -l, except that verbose ACL information is displayed as
757 well as the -l output. ACL information is displayed even if the
758 file or directory doesn't have an ACL.
759
760
761 -V
762
763 The same as -l, except that compact ACL information is displayed
764 after the -l output.
765
766 The -V option is only applicable to file systems that support NFSv4
767 ACLs, such as the Solaris ZFS file system.
768
769 The format of the displayed ACL is as follows:
770
771 entry_type : permissions : inheritance_flags : access_type
772
773
774 entry_type is displayed as one of the following:
775
776 user:username
777
778 Additional user access for username.
779
780
781 group:groupname
782
783 Additional group access for group groupname.
784
785
786 owner@
787
788 File owner.
789
790
791 group@
792
793 File group owner.
794
795
796 everyone@
797
798 Everyone access, including file owner and file group owner.
799 This is not equivalent to the POSIX other class.
800
801 The following permissions, supported by the NFSv4 ACL model, are
802 displayed by using the -v or -V options:
803
804 read_data (r)
805
806 Permission to read the data of a file.
807
808
809 list_directory (r)
810
811 Permission to list the contents of a directory.
812
813
814 write_data (w)
815
816 Permission to modify a file's data. anywhere in the file's
817 offset range.
818
819
820 add_file (w)
821
822 Permission to add a new file to a directory.
823
824
825 append_data (p)
826
827 The ability to modify a file's data, but only starting at EOF.
828
829
830 add_subdirectory (p)
831
832 Permission to create a subdirectory to a directory.
833
834
835 read_xattr (R)
836
837 Ability to read the extended attributes of a file.
838
839
840 write_xattr (W)
841
842 Ability to create extended attributes or write to the extended
843 attribute directory.
844
845
846 execute (x)
847
848 Permission to execute a file.
849
850
851 read_attributes (a)
852
853 The ability to read basic attributes (non-ACLs) of a file.
854
855
856 write_attributes (A)
857
858 Permission to change the times associated with a file or
859 directory to an arbitrary value.
860
861
862 delete (d)
863
864 Permission to delete a file.
865
866
867 delete_child (D)
868
869 Permission to delete a file within a directory.
870
871
872 read_acl (c)
873
874 Permission to read the ACL of a file.
875
876
877 write_acl (C)
878
879 Permission to write the ACL of a file.
880
881
882 write_owner (o)
883
884 Permission to change the owner of a file.
885
886
887 synchronize (s)
888
889 Permission to access file locally at server with synchronize
890 reads and writes.
891
892
893 -
894
895 No permission granted
896
897 The following inheritance flags, supported by the NFSv4 ACL model,
898 are displayed by using the -v or -V options:
899
900 file_inherit (f)
901
902 Inherit to all newly created files.
903
904
905 dir_inherit (d)
906
907 Inherit to all newly created directories.
908
909
910 inherit_only (i)
911
912 When placed on a directory, do not apply to the directory, only
913 to newly created files and directories. This flag requires that
914 either file_inherit and or dir_inherit is also specified.
915
916
917 no_propagate (n)
918
919 Indicates that ACL entries should be inherited to objects in a
920 directory, but inheritance should stop after descending one
921 level. This flag is dependent upon either file_inherit and or
922 dir_inherit also being specified.
923
924
925 successful_access (S)
926
927 Indicates whether an alarm or audit record should be initiated
928 upon successful accesses. Used with audit/alarm ACE types.
929
930
931 failed_access (F)
932
933 Indicates whether an alarm or audit record should be initiated
934 when access fails. Used with audit/alarm ACE types.
935
936
937 inherited (I)
938
939 ACE was inherited.
940
941
942 -
943
944 No permission granted.
945
946 access_type is displayed as one of the following types:
947
948 alarm
949 Permission field that specifies permissions that should
950 trigger an alarm.
951
952
953 allow
954 Permission field that specifies allow permissions.
955
956
957 audit
958 Permission field that specifies permissions that should be
959 audited.
960
961
962 deny
963 Permission field that specifies deny permissions.
964
965 For example:
966
967 $ ls -dV /sandbox/dir.1
968 drwxr-xr-x+ 2 root root 2 Jan 17 15:09 dir.1
969 user:marks:r-------------:fd-----:allow
970 owner@:--------------:-------:deny
971 owner@:rwxp---A-W-Co-:-------:allow
972 group@:-w-p----------:-------:deny
973 group@:r-x-----------:-------:allow
974 everyone@:-w-p---A-W-Co-:-------:deny
975 everyone@:r-x---a-R-c--s:-------:allow
976 $
977 ||||||||||||||||:||||||+ inherited access
978 ||||||||||||||:||||||+ failed access
979 ||||||||||||||:|||||+--success access
980 ||||||||||||||:||||+-- no propagate
981 ||||||||||||||:|||+--- inherit only
982 ||||||||||||||:||+---- directory inherit
983 ||||||||||||||:|+----- file inherit
984 ||||||||||||||
985 ||||||||||||||+ sync
986 |||||||||||||+- change owner
987 ||||||||||||+-- write ACL
988 |||||||||||+--- read ACL
989 ||||||||||+---- write extended attributes
990 |||||||||+----- read extended attributes
991 ||||||||+------ write attributes
992 |||||||+------- read attributes
993 ||||||+-------- delete child
994 |||||+--------- delete
995 ||||+---------- append
996 |||+----------- execute
997 ||+------------ write data
998 |+------------- read data
999
1000
1001
1002
1003 -w cols
1004 --width cols
1005
1006 Multi-column output where the column width is forced to cols.
1007
1008
1009 -x
1010
1011 Multi-column output with entries sorted across rather than down the
1012 page.
1013
1014
1015 -1
1016
1017 Prints one entry per line of output.
1018
1019
1020 -@
1021
1022 The same as -l, except that extended attribute information
1023 overrides ACL information. An @ is displayed after the file
1024 permission bits for files that have extended attributes.
1025
1026
1027 -/ c | v
1028
1029 The same as -l, and in addition displays the extended system
1030 attributes associated with the file when extended system attributes
1031 are fully supported by the underlying file system. The option -/
1032 supports two option arguments c (compact mode) and v (verbose
1033 mode).
1034
1035 appendonly
1036
1037 Allows a file to be modified only at offset EOF. Attempts to
1038 modify a file at a location other than EOF fails with EPERM.
1039
1040
1041 archive
1042
1043 Indicates if a file has been modified since it was last backed
1044 up. Whenever the modification time (mtime) of a file is changed
1045 the archive attribute is set.
1046
1047
1048 av_modified
1049
1050 ZFS sets the anti-virus attribute which whenever a file's
1051 content or size changes or when the file is renamed.
1052
1053
1054 av_quarantined
1055
1056 Anti-virus software sets to mark a file as quarantined.
1057
1058
1059 crtime
1060
1061 Timestamp when a file is created.
1062
1063
1064 hidden
1065
1066 Marks a file as hidden.
1067
1068
1069 immutable
1070
1071 Prevents the content of a file from being modified. Also
1072 prevents all metadata changes, except for access time updates.
1073 When placed on a directory, prevents the deletion and creation
1074 of files in the directories. Attempts to modify the content of
1075 a file or directory marked as immutable fail with EPERM.
1076 Attempts to modify any attributes (with the exception of access
1077 time and, with the proper privileges, the immutable) of a file
1078 marked as immutable fails with EPERM.
1079
1080
1081 nodump
1082
1083 Solaris systems have no special semantics for this attribute.
1084
1085
1086 nounlink
1087
1088 Prevents a file from being deleted. On a directory, the
1089 attribute also prevents any changes to the contents of the
1090 directory. That is, no files within the directory can be
1091 removed or renamed. The errno EPERM is returned when attempting
1092 to unlink or rename files and directories that are marked as
1093 nounlink.
1094
1095
1096 offline
1097
1098 Indicate that a file is offline. Solaris systems have no
1099 special semantics for this attribute.
1100
1101
1102 readonly
1103
1104 Marks a file as readonly. Once a file is marked as readonly the
1105 content data of the file cannot be modified. Other metadata for
1106 the file can still be modified.
1107
1108
1109 sparse
1110
1111 Indicate that a file can be interpreted as sparse. It does not
1112 indicate that the file is actually sparse or not. The sparse
1113 attribute is cleared when the file is truncated to zero length.
1114 Solaris systems have no other special semantics for this
1115 attribute.
1116
1117
1118 system
1119
1120 Solaris systems have no special semantics for this attribute.
1121
1122
1123
1124
1125 The display characters used in compact mode (-/ c) are as follows:
1126
1127 Attribute Name Display
1128 archive A
1129 hidden H
1130 readonly R
1131 system S
1132 appendonly a
1133 nodump d
1134 immutable i
1135 av_modified m
1136 av_quarantined q
1137 nounlink u
1138 offline O
1139 sparse s
1140
1141
1142
1143
1144 The display in verbose mode (-/ v) uses full attribute names when it is
1145 set and the name prefixed by 'no' when it is not set.
1146
1147
1148 The attribute name crtime and all other timestamps are handled by the
1149 option -% with the respective timestamp option arguments and also with
1150 all option argument. The display positions are as follows: The display
1151 in verbose mode (-/ v) uses full attribute names when it is set and
1152 the name prefixed by no when it is not set. The attribute name crtime
1153 and all other timestamps are handled by the option -% with the
1154 respective timestamp option arguments and also with all option
1155 argument.
1156
1157
1158 The display positions are as follows:
1159
1160 {||||||||||||}
1161 |||||||||||+- s (sparse)
1162 ||||||||||+-- O (offline)
1163 |||||||||+--- u (nounlink)
1164 ||||||||+---- q (av_quarantined)
1165 |||||||+----- m (av_modified)
1166 ||||||+------ i (immutable)
1167 |||||+------- d (nodump)
1168 ||||+-------- a (appendonly)
1169 |||+--------- S (system)
1170 ||+---------- R (readonly)
1171 |+----------- H (hidden)
1172 +------------ A (archive)
1173
1174
1175
1176 -% atime | crtime | ctime | mtime | all
1177
1178
1179
1180 atime
1181
1182 Equivalent to -u.
1183
1184
1185 crtime
1186
1187 Uses the creation time of the file for sorting or printing.
1188
1189
1190 ctime
1191
1192 Equivalent to -c.
1193
1194
1195 mtime
1196
1197 Uses the last modification time of the file contents for sorting or
1198 printing.
1199
1200
1201
1202 If extended system attributes are not supported or if the user does not
1203 have read permission on the file or if the crtime extended attribute is
1204 not set, crtime is treated as a synonym for mtime.
1205
1206
1207 When option argument all is specified, all available timestamps are
1208 printed which includes atime, ctime, mtime and on the extended system
1209 attribute supporting file systems, crtime (create time). The option -%
1210 all does not effect which timestamp is displayed in long format and
1211 does not affect sorting.
1212
1213 --block-size size
1214
1215 Display sizes in multiples of size. Size can be scaled by suffixing
1216 one of YyZzEePpTtGgMmKk. Additionally, a B can be placed at the end
1217 to indicate powers of 10 instead of 2. For example, . 10mB means
1218 blocks of 10000000 bytes while 10m means blocks of 10*2^20 --
1219 10485760 -- bytes. This is mutually exclusive with the -h option.
1220
1221
1222 --color [=when]
1223 --colour[=when]
1224
1225 Display filenames using color on color-capable terminals. when is
1226 an optional argument that determines when to display color output.
1227
1228 Possible values for when are:
1229
1230 always
1231 yes
1232 force
1233
1234 Always use color.
1235
1236
1237 auto
1238 tty
1239 if-tty
1240
1241 Use color if a terminal is present.
1242
1243
1244 no
1245 never
1246 none
1247
1248 Never use color. This is the default
1249
1250 See COLOR OUTPUT for information on how to control the output
1251 colors.
1252
1253
1254 --file-type
1255
1256 Display a suffix after a file depending on it's type, similar to
1257 the -F option, except * is not appended to executable files.
1258
1259
1260 -si
1261 --
1262
1263 Display human scaled sizes similar to the -h option, except values
1264 are repeatedly divided by 1000 instead of 1024. The last option
1265 --si or -h determines the divisor used.
1266
1267
1268 --time-style style
1269
1270 Display times using the specified style. This does not effect the
1271 times displayed for extended attributes (-%).
1272
1273 Possible values for style are:
1274
1275 full-iso
1276
1277 Equivalent to -E.
1278
1279
1280 long-iso
1281
1282 Display in YYYY-MM-DD HH:MM for all files.
1283
1284
1285 iso
1286
1287 Display older files using YYYY-MM-DD and newer files with MM-DD
1288 HH:MM.
1289
1290
1291 locale
1292
1293 Use the default locale format for old and new files. This is
1294 the default.
1295
1296
1297 +FORMAT
1298
1299 Use a custom format. Values are the same as described in
1300 strftime(3C). If a NEWLINE appears in the string, the first
1301 line is used for older files and the second line is used for
1302 newer files. Otherwise, the given format is used for all files.
1303
1304
1305
1306 /usr/bin/ls
1307 -F
1308
1309 Marks directories with a trailing slash (/), doors with a trailing
1310 greater-than sign (>), executable files with a trailing asterisk
1311 (*), FIFOs with a trailing vertical bar (|), symbolic links with a
1312 trailing "at" sign (@), and AF_UNIX address family sockets with a
1313 trailing equals sign (=). Follows symlinks named as operands.
1314
1315
1316 --file-type
1317
1318 Marks entries as with -F with the exception of executable files.
1319 Executable files are not marked. Follows symlinks named as
1320 operands.
1321
1322
1323
1324 Specifying more than one of the options in the following mutually
1325 exclusive pairs is not considered an error: -C and -l (ell), -m and -l
1326 (ell), -x and -l (ell), -@ and -l (ell). The -l option overrides the
1327 other option specified in each pair.
1328
1329
1330 Specifying more than one of the options in the following mutually
1331 exclusive groups is not considered an error: -C and -1 (one), -H and
1332 -L, -c and -u, and -e and -E, and -t and -S. The last option specifying
1333 a specific timestamp (-c, -u, -% atime , -% crtime, -% ctime, and -%
1334 mtime) determines the timestamps used for sorting or in long format
1335 listings. The last option -t, -S, or -U determines the sorting
1336 behavior.
1337
1338 /usr/xpg4/bin/ls
1339 -F
1340
1341 Marks directories with a trailing slash (/), doors with a trailing
1342 greater-than sign (>), executable files with a trailing asterisk
1343 (*), FIFOs with a trailing vertical bar (|), symbolic links with a
1344 trailing "at" sign (@), and AF_UNIX address family sockets with a
1345 trailing equals sign (=). Follows symlinks named as operands.
1346
1347
1348 --file-type
1349
1350 Marks entries as with -F with the exception of executable files.
1351 Executable files are not marked. Follows symlinks named as
1352 operands.
1353
1354
1355
1356 Specifying more than one of the options in the following groups of
1357 mutually exclusive options is not considered an error: -C and -l (ell),
1358 -m and -l (ell), -x and -l (ell), -@ and -l (ell), -C and -1 (one), -H
1359 and -L, -c and -u, -e and -E, -t and -S and -U. The last option
1360 specifying a specific timestamp (-c, -u, -% atime , -% crtime, -%
1361 ctime, and -% mtime) determines the timestamps used for sorting or in
1362 long format listings. The last -t, -S, or -U option determines the
1363 sorting behavior.
1364
1365 /usr/xpg6/bin/ls
1366 -F
1367
1368 Marks directories with a trailing slash (/), doors with a trailing
1369 greater-than sign (>), executable files with a trailing asterisk
1370 (*), FIFOs with a trailing vertical bar (|), symbolic links with a
1371 trailing "at" sign (@), and AF_UNIX address family sockets with a
1372 trailing equals sign (=). Does not follow symlinks named as
1373 operands unless the -H or -L option is specified.
1374
1375
1376 --file-type
1377
1378 Marks entries as with -F with the exception of executable files.
1379 Executable files are not marked. Does not follow symlinks named as
1380 operands unless the -H or -L option is specified.
1381
1382
1383
1384 Specifying more than one of the options in the following mutually
1385 exclusive pairs is not considered an error: -C and -l (ell), m and
1386 -l(ell), -x and -l (ell), -@ and -l (ell), -C and -1 (one), -H and --L,
1387 -c and -u, -e and -E, -t and -S and -U. The last option specifying a
1388 specific timestamp (-c, -u, -% atime , -% crtime, -% ctime, and -%
1389 mtime) determines the timestamps used for sorting or in long format
1390 listings. The last -t, -S, or -U option determines the sorting
1391 behavior.
1392
1393 OPERANDS
1394 The following operand is supported:
1395
1396 file
1397
1398 A path name of a file to be written. If the file specified is not
1399 found, a diagnostic message is output on standard error.
1400
1401
1402 USAGE
1403 See largefile(5) for the description of the behavior of ls when
1404 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
1405
1406 EXAMPLES
1407 Example 1 Viewing File Permissions
1408
1409
1410 The following example shows how to display detailed information about a
1411 file.
1412
1413
1414 % ls -l file.1
1415 -rw-r--r-- 1 gozer staff 206663 Mar 14 10:15 file.1
1416
1417
1418
1419
1420 The permissions string above (-rw-r--r--) describes that the file owner
1421 has read and write permissions, the owning group has read permissions,
1422 and others have read permissions.
1423
1424
1425
1426 The following example shows how to display detailed information about a
1427 directory.
1428
1429
1430 % ls -ld test.dir
1431 drwxr-xr-x 2 gozer staff 2 Mar 14 10:17 test.dir
1432
1433
1434
1435
1436 The permissions string above (drwxr-xr-x) describes that the directory
1437 owner has read, write, and search permissions, the owning group has
1438 read and search permissions, and others have read and search
1439 permissions.
1440
1441
1442
1443 Another example of listing file permissions is as follows:
1444
1445
1446 % ls -l file.2
1447 -rw-rwl--- 1 gozer staff 206663 Mar 14 10:47 file.2
1448
1449
1450
1451
1452 The permissions string above (-rw-rwl---) describes that the file owner
1453 has read and write permissions, the owning group has read and write
1454 permissions, and the file can be locked during access.
1455
1456
1457 Example 2 Displaying ACL Information on Files and Directories
1458
1459
1460 The following example shows how to display verbose ACL information on a
1461 ZFS file.
1462
1463
1464 % ls -v file.1
1465 -rw-r--r-- 1 marks staff 206663 Mar 14 10:15 file.1
1466 0:owner@:execute:deny
1467 1:owner@:read_data/write_data/append_data/write_xattr/write_attributes
1468 /write_acl/write_owner:allow
1469 2:group@:write_data/append_data/execute:deny
1470 3:group@:read_data:allow
1471 4:everyone@:write_data/append_data/write_xattr/execute/write_attributes
1472 /write_acl/write_owner:deny
1473 5:everyone@:read_data/read_xattr/read_attributes/read_acl/synchronize
1474 :allow
1475
1476
1477
1478
1479 The following example shows how to display compact ACL information on a
1480 ZFS directory.
1481
1482
1483 % ls -dV test.dir
1484 drwxr-xr-x 2 marks staff 2 Mar 14 10:17 test.dir
1485 owner@:--------------:------:deny
1486 owner@:rwxp---A-W-Co-:------:allow
1487 group@:-w-p----------:------:deny
1488 group@:r-x-----------:------:allow
1489 everyone@:-w-p---A-W-Co-:------:deny
1490 everyone@:r-x---a-R-c--s:------:allow
1491
1492
1493
1494
1495 The following example illustrates the ls -v behavior when listing ACL
1496 information on a UFS file.
1497
1498
1499 $ ls -v file.3
1500 -rw-r--r-- 1 root root 2703 Mar 14 10:59 file.3
1501 0:user::rw-
1502 1:group::r-- #effective:r--
1503 2:mask:r--
1504 3:other:r--
1505
1506
1507
1508 Example 3 Printing the Names of All Files
1509
1510
1511 The following example prints the names of all files in the current
1512 directory, including those that begin with a dot (.), which normally do
1513 not print:
1514
1515
1516 example% ls -a
1517
1518
1519
1520 Example 4 Providing File Information
1521
1522
1523 The following example provides file information:
1524
1525
1526 example% ls -aisn
1527
1528
1529
1530
1531 This command provides information on all files, including those that
1532 begin with a dot (a), the i-number, the memory address of the i-node
1533 associated with the file--printed in the left-hand column (i); the size
1534 (in blocks) of the files, printed in the column to the right of the i-
1535 numbers (s); finally, the report is displayed in the numeric version of
1536 the long list, printing the UID (instead of user name) and GID (instead
1537 of group name) numbers associated with the files.
1538
1539
1540
1541 When the sizes of the files in a directory are listed, a total count of
1542 blocks, including indirect blocks, is printed.
1543
1544
1545 Example 5 Providing Extended System Attributes Information
1546
1547 example% ls -/ c file (extended system attribute in compact mode)
1548 -rw-r--r-- 1 root root 0 May 10 14:17 file
1549 {AHRSadim-u--}
1550
1551
1552
1553
1554 In this example, av_quarantined, offline, and sparse are not set.
1555
1556 example% ls -/ v file (extended system attribute in verbose mode)
1557 -rw-r--r-- 1 root root 0 May 10 14:17 file
1558 {archive,hidden,readonly,system,\
1559 appendonly,nodump,immutable,av_modified,\
1560 noav_quarantined,nounlink,nooffline,\
1561 nosparse}
1562
1563 example% ls -/ v file (no extended system attribute)
1564 -rw-r--r-- 1 root staff 0 May 16 14:48 file
1565 {}
1566
1567 example% ls -/ c file (extended system attribute
1568 supported file system)
1569
1570 -rw-r--r-- 1 root staff 3 Jun 4 22:04 file
1571 {A------m----}
1572
1573
1574
1575
1576 archive and av_modified attributes are set by default on an extended
1577 system attribute supported file.
1578
1579 example% ls -/ c -%crtime file
1580
1581 -rw-r--r-- root root 0 May 10 14:17 file
1582 {AHRSadim-u--}
1583
1584
1585
1586
1587 This example displays the timestamp as the creation time:
1588
1589 example% ls -l -%all file
1590 -rw-r--r-- 1 root root 0 May 10 14:17 file
1591 timestamp: atime Jun 14 08:47:37 2007
1592 timestamp: ctime May 10 14:20:23 2007
1593 timestamp: mtime May 10 14:17:56 2007
1594 timestamp: crtime May 10 14:17:56 2007
1595
1596 example% ls -%crtime -tl file*
1597
1598 -rw-r--r-- 1 foo staff 3 Jun 4 22:04 file1
1599 -rw-r--r-- 1 root root 0 May 10 14:17 file
1600 -rw-r--r-- 1 foo staff 0 May 9 13:49 file.1
1601
1602
1603
1604
1605 In this example the files are sorted by creation time.
1606
1607 ENVIRONMENT VARIABLES
1608 See environ(5) for descriptions of the following environment variables
1609 that affect the execution of ls: LANG, LC_ALL, LC_COLLATE, LC_CTYPE,
1610 LC_TIME, LC_MESSAGES, NLSPATH, and TZ.
1611
1612 COLUMNS
1613
1614 Determines the user's preferred column position width for writing
1615 multiple text-column output. If this variable contains a string
1616 representing a decimal integer, the ls utility calculates how many
1617 path name text columns to write (see -C) based on the width
1618 provided. If COLUMNS is not set or is invalid, 80 is used. The
1619 column width chosen to write the names of files in any given
1620 directory is constant. File names are not be truncated to fit into
1621 the multiple text-column output.
1622
1623
1624 LS_COLORS
1625
1626 Determines the coloring scheme used when displaying color output.
1627 If not set and color output is specified, a default scheme is used.
1628 If TERM is not set, no color output is used.
1629
1630
1631 TERM
1632
1633 Determine the terminal type. If this variable is unset or NULL, no
1634 color output is generated regardless of the value of the --color
1635 option.
1636
1637
1638 EXIT STATUS
1639 0
1640 All information was written successfully.
1641
1642
1643 >0
1644 An error occurred.
1645
1646
1647 FILES
1648 /etc/group
1649
1650 group IDs for ls -l and ls -g
1651
1652
1653 /etc/passwd
1654
1655 user IDs for ls -l and ls -o
1656
1657
1658 /usr/share/lib/terminfo/?/*
1659
1660 terminal information database
1661
1662
1663 ATTRIBUTES
1664 See attributes(5) for descriptions of the following attributes:
1665
1666 /usr/bin/ls
1667
1668 +--------------------+-----------------+
1669 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
1670 +--------------------+-----------------+
1671 |CSI | Enabled |
1672 +--------------------+-----------------+
1673 |Interface Stability | Committed |
1674 +--------------------+-----------------+
1675 |Standard | See below. |
1676 +--------------------+-----------------+
1677
1678
1679 For all options except -A, -b, -e, -E, -h, -S, U -v, -V, -@, -/, -%,
1680 --all, --almost-all, --block-size, --classify, --color, --colour,
1681 --dereference, --dereference-command-line, --escape, --file-type,
1682 --full-time, --human-readable, --ignore-backups, --inode, --no-group,
1683 --numeric-uid-gid, --reverse, --recursive, --si, --size, and --time-
1684 style, see standards(5).
1685
1686 /usr/xpg4/bin/ls
1687
1688 +--------------------+-----------------+
1689 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
1690 +--------------------+-----------------+
1691 |CSI | Enabled |
1692 +--------------------+-----------------+
1693 |Interface Stability | Committed |
1694 +--------------------+-----------------+
1695 |Standard | See below. |
1696 +--------------------+-----------------+
1697
1698
1699 For all options except -A, -b, -e, -E, -h, -S, U -v, -V, -@, -/, -%,
1700 --all, --almost-all, --block-size, --classify, --color, --colour,
1701 --dereference, --dereference-command-line, --escape, --file-type,
1702 --full-time, --human-readable, --ignore-backups, --inode, --no-group,
1703 --numeric-uid-gid, --reverse, --recursive, --si, --size, and --time-
1704 style, see standards(5).
1705
1706 /usr/xpg6/bin/ls
1707
1708 +--------------------+-----------------+
1709 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
1710 +--------------------+-----------------+
1711 |CSI | Enabled |
1712 +--------------------+-----------------+
1713 |Interface Stability | Committed |
1714 +--------------------+-----------------+
1715 |Standard | See below. |
1716 +--------------------+-----------------+
1717
1718
1719 For all options except -A, -b, -e, -E, -h, -S, U -v, -V, -@, -/, -%,
1720 --all, --almost-all, --block-size, --classify, --color, --colour,
1721 --dereference, --dereference-command-line, --escape, --file-type,
1722 --full-time, --human-readable, --ignore-backups, --inode, --no-group,
1723 --numeric-uid-gid, --reverse, --recursive, --si, --size, and --time-
1724 style, see standards(5).
1725
1726 SEE ALSO
1727 chmod(1), cp(1), setfacl(1), fgetattr(3C), strftime(3C), terminfo(4),
1728 acl(5), attributes(5), environ(5), fsattr(5), largefile(5),
1729 standards(5), idmapd(1M)
1730
1731 NOTES
1732 Unprintable characters in file names can confuse the columnar output
1733 options.
1734
1735
1736 The total block count is incorrect if there are hard links among the
1737 files.
1738
1739
1740 The sort order of ls output is affected by the locale and can be
1741 overridden by the LC_COLLATE environment variable. For example, if
1742 LC_COLLATE equals C, dot files appear first, followed by names
1743 beginning with upper-case letters, then followed by names beginning
1744 with lower-case letters. But if LC_COLLATE equals en_US.ISO8859-1, then
1745 leading dots as well as case are ignored in determining the sort order.
1746
1747
1748 For additional information regarding Windows Security Identifiers,
1749 consult Microsoft support document, Well-known security identifiers in
1750 Windows operating systems, which can be found at Microsoft's support
1751 site: https://support.microsoft.com/en-us/kb/243330/.
1752
1753
1754
1755 July 1, 2016 LS(1)