Commit | Line | Data |
---|---|---|
a93cea6a | 1 | .\" Copyright 1980, 1990, 1991 The Regents of the University of California. |
356242cc | 2 | .\" All rights reserved. |
a10206cc | 3 | .\" |
cf136d2c KB |
4 | .\" This code is derived from software contributed to Berkeley by |
5 | .\" the Institute of Electrical and Electronics Engineers, Inc. | |
6 | .\" | |
a93cea6a | 7 | .\" %sccs.include.redist.roff% |
356242cc | 8 | .\" |
4933888a | 9 | .\" @(#)ls.1 6.21 (Berkeley) %G% |
a10206cc | 10 | .\" |
a93cea6a CL |
11 | .Dd |
12 | .Dt LS 1 | |
13 | .Os | |
14 | .Sh NAME | |
15 | .Nm ls | |
16 | .Nd list directory contents | |
17 | .Sh SYNOPSIS | |
18 | .Nm ls | |
19 | .Op Fl CFRacdilqrstu1 | |
20 | .Op Ar file ... | |
21 | .Sh DESCRIPTION | |
22 | For each operand that names a | |
23 | .Ar file | |
24 | of a type other than | |
25 | directory, | |
26 | .Nm ls | |
27 | displays its name as well as any requested, | |
28 | associated information. | |
29 | For each operand that names a | |
30 | .Ar file | |
31 | of type directory, | |
32 | .Nm ls | |
33 | displays the names of files contained | |
34 | within that directory, as well as any requested, associated | |
35 | information. | |
36 | .Pp | |
37 | If no operands are given, the contents of the current | |
38 | directory are displayed. | |
39 | If more than one operand is given, | |
40 | non-directory operands are displayed first; directory | |
41 | and non-directory operands are sorted separately and in | |
42 | lexicographical order. | |
43 | .Pp | |
44 | The following options are available: | |
45 | .Bl -tag -width indent | |
46 | .It Fl A | |
47 | List all entries except for | |
48 | .Ql \&. | |
49 | and | |
50 | .Ql \&.. . | |
c699b55c | 51 | Always set for the super-user. |
a93cea6a CL |
52 | .It Fl C |
53 | Force multi-column output; this is the default when output is to a terminal. | |
54 | .It Fl F | |
55 | Display a slash (/) immediately after each pathname | |
56 | that is a directory, an asterisk (*) after each that is | |
57 | executable, | |
58 | and an at sign (@) after each symbolic link. | |
4933888a KB |
59 | .\" and a vertical bar (|) after each that is a |
60 | .\" .Tn FIFO . | |
a93cea6a | 61 | .It Fl L |
30149789 KM |
62 | If argument is a symbolic link, list the file or directory the link references |
63 | rather than the link itself. | |
a93cea6a CL |
64 | .It Fl R |
65 | Recursively list subdirectories encountered. | |
66 | .It Fl T | |
e05a6377 KB |
67 | Display complete time information for the file, including |
68 | month, day, hour, minute, second, and year. | |
a93cea6a CL |
69 | .It Fl a |
70 | Include directory entries whose names begin with a | |
71 | dot (.). | |
72 | .It Fl c | |
73 | Use time when file status was last changed for sorting or printing. | |
74 | .It Fl d | |
8b5f57b4 KB |
75 | Directories are listed as plain files (not searched recursively) and |
76 | symbolic links in the argument list are not indirected through. | |
a93cea6a CL |
77 | .It Fl f |
78 | Output is not sorted. | |
79 | .It Fl g | |
80 | Include the group ownership of the file in a long | |
81 | .Pq Fl l | |
82 | output | |
83 | .Pq Fl lg . | |
84 | If the group is not a known group name, the numeric ID | |
85 | is printed. | |
86 | .It Fl i | |
87 | For each file, print the file's file serial number (inode number). | |
a93cea6a CL |
88 | .It Fl l |
89 | (The lowercase letter ``ell.'') List in long format. (See below.) | |
90 | If the output is to a terminal, a total sum for all the file | |
91 | sizes is output on a line before the long listing. | |
32980675 KM |
92 | .It Fl g |
93 | Include the file flags in a long | |
94 | .Pq Fl l | |
95 | output | |
a93cea6a CL |
96 | .It Fl q |
97 | Force printing of non-graphic characters in file names as | |
98 | the character `?'; this is the default when output is to a terminal. | |
99 | .It Fl r | |
100 | Reverse the order of the sort to get reverse | |
101 | lexicographical order or the oldest entries first. | |
102 | .It Fl s | |
4933888a KB |
103 | Display the number of file system blocks actually used by each file, in units |
104 | of 512 bytes, where partial units are rounded up to the next integer value. | |
a93cea6a CL |
105 | If the output is to a terminal, a total sum for all the file |
106 | sizes is output on a line before the listing. | |
107 | .It Fl t | |
108 | Sort by time modified (most recently modified | |
109 | first) before sorting the operands by lexicographical | |
110 | order. | |
111 | .It Fl u | |
112 | Use time of last access, | |
113 | instead of last modification | |
114 | of the file for sorting | |
115 | .Pq Fl t | |
116 | or printing | |
117 | .Pq Fl l . | |
118 | .It Fl \&1 | |
119 | (The numeric digit ``one.'') Force output to be | |
120 | one entry per line. | |
121 | This is the default when | |
122 | output is not to a terminal. | |
123 | .El | |
124 | .Pp | |
c699b55c | 125 | The |
a93cea6a CL |
126 | .Fl 1 , |
127 | .Fl C , | |
c699b55c | 128 | and |
a93cea6a | 129 | .Fl l |
c699b55c KB |
130 | options all override each other; the last one specified determines |
131 | the format used. | |
a93cea6a | 132 | .Pp |
c699b55c | 133 | The |
a93cea6a | 134 | .Fl c , |
c699b55c | 135 | and |
a93cea6a | 136 | .Fl u |
c699b55c KB |
137 | options override each other; the last one specified determines |
138 | the file time used. | |
a93cea6a CL |
139 | .Pp |
140 | By default, | |
141 | .Nm ls | |
142 | lists one entry per line to standard | |
143 | output; the exceptions are to terminals or when the | |
144 | .Fl C | |
145 | option is specified. | |
146 | .Pp | |
147 | File information is displayed with one or more | |
148 | <blank>s separating the information associated with the | |
149 | .Fl i , | |
150 | .Fl s , | |
151 | and | |
152 | .Fl l | |
153 | options. | |
154 | .Ss The Long Format | |
155 | If the | |
156 | .Fl l | |
157 | option is given, the following information | |
4933888a | 158 | is displayed for each file: |
a93cea6a CL |
159 | file mode, |
160 | number of links, owner name, | |
161 | .\" group name, | |
162 | number of bytes in the file, abbreviated | |
163 | month, day-of-month file was last modified, | |
164 | hour file last modified, minute file last | |
165 | modified, and the pathname. | |
4933888a KB |
166 | In addition, for each directory whose contents are displayed, the total |
167 | number of 512-byte blocks used by the files in the directory is displayed | |
168 | on a line by itself immediately before the information for the files in the | |
169 | directory. | |
a93cea6a CL |
170 | .Pp |
171 | If the owner name is not a known user name | |
172 | the numeric ID is displayed. | |
173 | .Pp | |
174 | If the file is a character special or block special file, | |
175 | the major and minor device numbers for the file are displayed | |
176 | in the size field. If the file is a symbolic link the pathname of the | |
177 | linked-to file is preceded by | |
178 | .Dq \-> . | |
179 | .Pp | |
180 | The file mode printed under the -l option consists of the | |
181 | the entry type, owner permissions, and group permissions. | |
182 | The entry type character describes the type of file, as | |
183 | follows: | |
184 | .Pp | |
185 | .Bl -tag -width 4n -offset indent -compact | |
186 | .It Sy b | |
187 | Block special file. | |
188 | .It Sy c | |
189 | Character special file. | |
190 | .It Sy d | |
191 | Directory. | |
192 | .It Sy l | |
193 | Symbolic link. | |
194 | .It Sy s | |
195 | Socket link. | |
196 | .\" .It Sy p | |
197 | .\" .Tn FIFO . | |
198 | .It Sy \- | |
199 | Regular file. | |
200 | .El | |
201 | .Pp | |
202 | The next three fields | |
203 | are three characters each: | |
204 | owner permissions, | |
205 | group permissions, and | |
206 | other permissions. | |
207 | Each field has three character positions: | |
208 | .Bl -enum -offset indent | |
209 | .It | |
210 | If | |
211 | .Sy r , | |
212 | the file is readable; if | |
213 | .Sy \- , | |
214 | it is not readable. | |
215 | .It | |
216 | If | |
217 | .Sy w , | |
218 | the file is writable; if | |
219 | .Sy \- , | |
220 | it is not writable. | |
221 | .It | |
222 | The first of the following that applies: | |
223 | .Bl -tag -width 4n -offset indent | |
224 | .It Sy S | |
225 | If in the owner permissions, the file is not executable and | |
226 | set-user-ID mode is set. | |
227 | If in the group permissions, the file is not executable | |
228 | and set-group-ID mode is set. | |
229 | .It Sy s | |
230 | If in the owner permissions, the file is executable | |
231 | and set-user-ID mode is set. | |
232 | If in the group permissions, the file is executable | |
233 | and setgroup-ID mode is set. | |
234 | .It Sy x | |
235 | The file is executable or the directory is | |
236 | searchable. | |
237 | .It Sy \- | |
238 | The file is neither readable, writeable, exectutable, | |
239 | or set-user-ID or set-group-ID mode nor sticky. (See below.) | |
240 | .El | |
241 | .Pp | |
242 | These next two apply only to the third character in the last group | |
243 | (other permissions). | |
244 | .Bl -tag -width 4n -offset indent | |
245 | .It Sy T | |
246 | The sticky bit is set | |
247 | (mode | |
248 | .Li 1000 ) , | |
249 | but not execute or search permission. (See | |
250 | .Xr chmod 1 | |
251 | or | |
252 | .Xr sticky 8 . ) | |
253 | .It Sy t | |
254 | The sticky bit is set (mode | |
255 | .Li 1000 ) , | |
256 | and is searcheable or executable. | |
257 | (See | |
258 | .Xr chmod 1 | |
259 | or | |
260 | .Xr sticky 8 . ) | |
261 | .El | |
262 | .El | |
263 | .Pp | |
264 | The | |
265 | .Nm ls | |
266 | utility exits 0 on success, and >0 if an error occurs. | |
4933888a | 267 | .Sh ENVIRONMENTAL VARIABLES |
a93cea6a CL |
268 | The following environment variables affect the execution of |
269 | .Nm ls : | |
4933888a KB |
270 | .Bl -tag -width BLOCKSIZE |
271 | .It Ev BLOCKSIZE | |
272 | If the environmental variable | |
273 | .Ev BLOCKSIZE | |
274 | is set, the block counts | |
275 | (see | |
276 | .Fl s ) | |
277 | will be displayed in units of that size block. | |
a93cea6a CL |
278 | .It COLUMNS |
279 | If this variable contains a string representing a | |
280 | decimal integer, it is used as the | |
281 | column position width for displaying | |
282 | multiple-text-column output. | |
283 | The | |
284 | .Nm ls | |
285 | utility calculates how | |
286 | many pathname text columns to display | |
287 | based on the width provided. | |
288 | (See | |
289 | .Fl C . ) | |
290 | .El | |
291 | .Sh SEE ALSO | |
292 | .Xr chmod 1 , | |
293 | .Xr sticky 8 | |
294 | .Sh HISTORY | |
295 | A | |
296 | .Nm ls | |
297 | command appeared in | |
298 | .At v6 . | |
4933888a KB |
299 | .Sh STANDARDS |
300 | The | |
301 | .Nm ls | |
302 | function is expected to be a superset of the | |
303 | .St -p1003.2 | |
304 | specification. |