Commit | Line | Data |
---|---|---|
a10206cc KM |
1 | .\" Copyright (c) 1980 Regents of the University of California. |
2 | .\" All rights reserved. The Berkeley software License Agreement | |
3 | .\" specifies the terms and conditions for redistribution. | |
4 | .\" | |
4e9923b0 | 5 | .\" @(#)ls.1 6.9 (Berkeley) %G% |
a10206cc | 6 | .\" |
4a3d96b7 | 7 | .TH LS 1 "" |
a10206cc KM |
8 | .UC |
9 | .SH NAME | |
10 | ls \- list contents of directory | |
11 | .SH SYNOPSIS | |
12 | .B ls | |
13 | [ | |
4e9923b0 | 14 | .B \-acdgilqrstu1ACLFR |
a10206cc KM |
15 | ] name ... |
16 | .br | |
a10206cc KM |
17 | .SH DESCRIPTION |
18 | For each directory argument, | |
19 | .I ls | |
20 | lists the contents of the directory; | |
21 | for each file argument, | |
22 | .I ls | |
23 | repeats its name and any other information requested. | |
30149789 | 24 | By default, the output is sorted alphabetically. |
a10206cc KM |
25 | When no argument is given, the current directory is listed. |
26 | When several arguments are given, | |
27 | the arguments are first sorted appropriately, | |
30149789 | 28 | but file arguments are processed |
a10206cc KM |
29 | before directories and their contents. |
30 | .PP | |
30149789 | 31 | There are a large number of options: |
a10206cc | 32 | .TP |
30149789 | 33 | .B \-l |
a10206cc KM |
34 | List in long format, giving mode, number of links, owner, |
35 | size in bytes, and time of last modification | |
36 | for each file. | |
37 | (See below.) | |
38 | If the file is a special file the size field will instead contain | |
39 | the major and minor device numbers. | |
30149789 KM |
40 | If the file is a symbolic link the pathname of |
41 | the linked-to file is printed preceded by ``\->''. | |
42 | .TP | |
43 | .B \-g | |
44 | Include the group ownership of the file in a long output. | |
a10206cc | 45 | .TP |
30149789 | 46 | .B \-t |
a10206cc | 47 | Sort by time modified (latest first) instead of |
30149789 | 48 | by name. |
a10206cc | 49 | .TP |
30149789 KM |
50 | .B \-a |
51 | List all entries; in the absence of this option, entries whose | |
52 | names begin with a period | |
53 | .RB ( . ) | |
54 | are | |
55 | .I not | |
56 | listed. | |
a10206cc | 57 | .TP |
0a413117 KB |
58 | .B \-A |
59 | List all entries except for ``.'' and ``..''. Always set for the | |
60 | super-user. | |
61 | .TP | |
30149789 KM |
62 | .B \-s |
63 | Give size in kilobytes of each file. | |
a10206cc | 64 | .TP |
30149789 KM |
65 | .B \-d |
66 | If argument is a directory, list only its name; | |
67 | often used with \fB\-l\fR to get the status of a directory. | |
68 | .TP | |
69 | .B \-L | |
70 | If argument is a symbolic link, list the file or directory the link references | |
71 | rather than the link itself. | |
a10206cc | 72 | .TP |
30149789 | 73 | .B \-r |
ccc80378 MK |
74 | Reverse the order of sort to get reverse alphabetic |
75 | or oldest first as appropriate. | |
a10206cc | 76 | .TP |
30149789 | 77 | .B \-u |
a10206cc KM |
78 | Use time of last access instead of last |
79 | modification for sorting | |
30149789 KM |
80 | (with the \fB\-t\fP option) |
81 | and/or printing (with the \fB\-l\fP option). | |
a10206cc | 82 | .TP |
30149789 | 83 | .B \-c |
aa97bb7c | 84 | Use time when file status was last changed for sorting or printing. |
a10206cc | 85 | .TP |
30149789 KM |
86 | .B \-i |
87 | For each file, print the i-number in the first column of the report. | |
a10206cc | 88 | .TP |
30149789 KM |
89 | .B \-F |
90 | cause directories to be marked with a trailing `/', | |
91 | sockets with a trailing `=', | |
92 | symbolic links with a trailing `@', and executable | |
93 | files with a trailing `*'. | |
a10206cc | 94 | .TP |
30149789 KM |
95 | .B \-R |
96 | recursively list subdirectories encountered. | |
a10206cc | 97 | .TP |
30149789 KM |
98 | .B \-1 |
99 | force one entry per line output format; this is the default when | |
100 | output is not to a terminal. | |
a10206cc | 101 | .TP |
30149789 KM |
102 | .B \-C |
103 | force multi-column output; this is the default when output is to a terminal. | |
a10206cc | 104 | .TP |
30149789 | 105 | .B \-q |
a10206cc | 106 | force printing of non-graphic characters in file names as |
30149789 | 107 | the character `?'; this is the default when output is to a terminal. |
a10206cc KM |
108 | .PP |
109 | The mode printed under the | |
110 | .B \-l | |
111 | option contains 11 characters | |
112 | which are interpreted | |
113 | as follows: | |
114 | the first character is | |
115 | .TP 3 | |
30149789 | 116 | .B d |
a10206cc KM |
117 | if the entry is a directory; |
118 | .br | |
119 | .ns | |
120 | .TP 3 | |
30149789 | 121 | .B b |
a10206cc KM |
122 | if the entry is a block-type special file; |
123 | .br | |
124 | .ns | |
125 | .TP 3 | |
30149789 | 126 | .B c |
a10206cc KM |
127 | if the entry is a character-type special file; |
128 | .br | |
129 | .ns | |
130 | .TP 3 | |
30149789 KM |
131 | .B l |
132 | if the entry is a symbolic link; | |
133 | .br | |
134 | .ns | |
135 | .TP | |
136 | .B s | |
137 | if the entry is a socket, or | |
a10206cc KM |
138 | .br |
139 | .ns | |
140 | .TP 3 | |
141 | .B \- | |
142 | if the entry is a plain file. | |
143 | .PP | |
144 | The next 9 characters are interpreted | |
145 | as three sets of three bits each. | |
146 | The first set refers to owner permissions; | |
adbdb3c0 | 147 | the next refers to permissions to others in the same user-group; |
a10206cc KM |
148 | and the last to all others. |
149 | Within each set the three characters indicate | |
150 | permission respectively to read, to write, or to | |
151 | execute the file as a program. | |
152 | For a directory, `execute' permission is interpreted | |
30149789 | 153 | to mean permission to search the directory. |
a10206cc KM |
154 | The permissions are indicated as follows: |
155 | .TP 3 | |
156 | .B r | |
157 | if the file is readable; | |
158 | .br | |
159 | .ns | |
160 | .TP 3 | |
161 | .B w | |
162 | if the file is writable; | |
163 | .br | |
164 | .ns | |
165 | .TP 3 | |
166 | .B x | |
167 | if the file is executable; | |
168 | .br | |
169 | .ns | |
170 | .TP 3 | |
171 | .B \- | |
172 | if the indicated permission is not granted. | |
173 | .PP | |
303dbd7d KB |
174 | The group-execute permission character is given as \fBs\fP if the file has |
175 | the set-group-id bit set; likewise the user-execute permission character is | |
176 | given as \fBs\fP if the file has the set-user-id bit set. These are given | |
177 | as \fBS\fP (capitalized) if the corresponding execute permission is NOT | |
178 | set. | |
a10206cc KM |
179 | .PP |
180 | The last character of the mode (normally `x' or `\-') is | |
181 | .B t | |
182 | if the 1000 bit of the mode is on. | |
183 | See | |
184 | .IR chmod (1) | |
303dbd7d KB |
185 | for the meaning of this mode. This is given as \fBT\fP (capitalized) if the |
186 | corresponding execute permission is NOT set. | |
a10206cc KM |
187 | .PP |
188 | When the sizes of the files in a directory | |
189 | are listed, a total count of blocks, | |
190 | including indirect blocks is printed. | |
191 | .SH FILES | |
30149789 | 192 | /etc/passwd to get user id's for |
a10206cc KM |
193 | `ls \-l'. |
194 | .br | |
30149789 | 195 | /etc/group to get group id's for |
a10206cc KM |
196 | `ls \-g'. |
197 | .SH BUGS | |
198 | Newline and tab are considered printing characters in file names. | |
199 | .PP | |
200 | The output device is assumed to be 80 columns wide. | |
201 | .PP | |
202 | The option setting based on whether the output is a teletype is | |
203 | undesirable as ``ls\ \-s'' is much different than ``ls\ \-s\ |\ lpr''. | |
204 | On the other hand, not doing this setting would make old shell scripts | |
205 | which used | |
206 | .I ls | |
207 | almost certain losers. |