Commit | Line | Data |
---|---|---|
c2d21bc3 WJ |
1 | .\" Copyright 1980, 1990, 1991 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
4 | .\" This code is derived from software contributed to Berkeley by | |
5 | .\" the Institute of Electrical and Electronics Engineers, Inc. | |
6 | .\" | |
7 | .\" Redistribution and use in source and binary forms, with or without | |
8 | .\" modification, are permitted provided that the following conditions | |
9 | .\" are met: | |
10 | .\" 1. Redistributions of source code must retain the above copyright | |
11 | .\" notice, this list of conditions and the following disclaimer. | |
12 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer in the | |
14 | .\" documentation and/or other materials provided with the distribution. | |
15 | .\" 3. All advertising materials mentioning features or use of this software | |
16 | .\" must display the following acknowledgement: | |
17 | .\" This product includes software developed by the University of | |
18 | .\" California, Berkeley and its contributors. | |
19 | .\" 4. Neither the name of the University nor the names of its contributors | |
20 | .\" may be used to endorse or promote products derived from this software | |
21 | .\" without specific prior written permission. | |
22 | .\" | |
23 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
24 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
25 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
26 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
27 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
28 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
29 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
30 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
31 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
32 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
33 | .\" SUCH DAMAGE. | |
34 | .\" | |
35 | .\" @(#)ls.1 6.18 (Berkeley) 6/27/91 | |
36 | .\" | |
37 | .Dd June 27, 1991 | |
38 | .Dt LS 1 | |
39 | .Os | |
40 | .Sh NAME | |
41 | .Nm ls | |
42 | .Nd list directory contents. | |
43 | .Sh SYNOPSIS | |
44 | .Nm ls | |
45 | .Op Fl CFRacdilqrstu1 | |
46 | .Op Ar file ... | |
47 | .Sh DESCRIPTION | |
48 | For each operand that names a | |
49 | .Ar file | |
50 | of a type other than | |
51 | directory, | |
52 | .Nm ls | |
53 | displays its name as well as any requested, | |
54 | associated information. | |
55 | For each operand that names a | |
56 | .Ar file | |
57 | of type directory, | |
58 | .Nm ls | |
59 | displays the names of files contained | |
60 | within that directory, as well as any requested, associated | |
61 | information. | |
62 | .Pp | |
63 | If no operands are given, the contents of the current | |
64 | directory are displayed. | |
65 | If more than one operand is given, | |
66 | non-directory operands are displayed first; directory | |
67 | and non-directory operands are sorted separately and in | |
68 | lexicographical order. | |
69 | .Pp | |
70 | The following options are available: | |
71 | .Bl -tag -width indent | |
72 | .It Fl A | |
73 | List all entries except for | |
74 | .Ql \&. | |
75 | and | |
76 | .Ql \&.. . | |
77 | Always set for the super-user. | |
78 | .It Fl C | |
79 | Force multi-column output; this is the default when output is to a terminal. | |
80 | .It Fl F | |
81 | Display a slash (/) immediately after each pathname | |
82 | that is a directory, an asterisk (*) after each that is | |
83 | executable, | |
84 | and an at sign (@) after each symbolic link. | |
85 | .\"and a vertical bar (|) after | |
86 | .\"each that is a | |
87 | .\".Tn FIFO . | |
88 | .It Fl L | |
89 | If argument is a symbolic link, list the file or directory the link references | |
90 | rather than the link itself. | |
91 | .It Fl R | |
92 | Recursively list subdirectories encountered. | |
93 | .It Fl T | |
94 | Display complete time information for the file, including | |
95 | month, day, hour, minute, second, and year. | |
96 | .It Fl a | |
97 | Include directory entries whose names begin with a | |
98 | dot (.). | |
99 | .It Fl c | |
100 | Use time when file status was last changed for sorting or printing. | |
101 | .It Fl d | |
102 | Directories are listed as plain files (not searched recursively). | |
103 | .It Fl f | |
104 | Output is not sorted. | |
105 | .It Fl g | |
106 | Include the group ownership of the file in a long | |
107 | .Pq Fl l | |
108 | output | |
109 | .Pq Fl lg . | |
110 | If the group is not a known group name, the numeric ID | |
111 | is printed. | |
112 | .It Fl i | |
113 | For each file, print the file's file serial number (inode number). | |
114 | .It Fl k | |
115 | Modifies the | |
116 | .Fl s | |
117 | option, causing the sizes to be reported in kilobytes. | |
118 | .It Fl l | |
119 | (The lowercase letter ``ell.'') List in long format. (See below.) | |
120 | If the output is to a terminal, a total sum for all the file | |
121 | sizes is output on a line before the long listing. | |
122 | .It Fl q | |
123 | Force printing of non-graphic characters in file names as | |
124 | the character `?'; this is the default when output is to a terminal. | |
125 | .It Fl r | |
126 | Reverse the order of the sort to get reverse | |
127 | lexicographical order or the oldest entries first. | |
128 | .It Fl s | |
129 | Display the number of file system bytes actually | |
130 | used by each file, in units of 512, where partial | |
131 | units are rounded up to the next integer value. | |
132 | If the output is to a terminal, a total sum for all the file | |
133 | sizes is output on a line before the listing. | |
134 | .It Fl t | |
135 | Sort by time modified (most recently modified | |
136 | first) before sorting the operands by lexicographical | |
137 | order. | |
138 | .It Fl u | |
139 | Use time of last access, | |
140 | instead of last modification | |
141 | of the file for sorting | |
142 | .Pq Fl t | |
143 | or printing | |
144 | .Pq Fl l . | |
145 | .It Fl \&1 | |
146 | (The numeric digit ``one.'') Force output to be | |
147 | one entry per line. | |
148 | This is the default when | |
149 | output is not to a terminal. | |
150 | .El | |
151 | .Pp | |
152 | The | |
153 | .Fl 1 , | |
154 | .Fl C , | |
155 | and | |
156 | .Fl l | |
157 | options all override each other; the last one specified determines | |
158 | the format used. | |
159 | .Pp | |
160 | The | |
161 | .Fl c , | |
162 | and | |
163 | .Fl u | |
164 | options override each other; the last one specified determines | |
165 | the file time used. | |
166 | .Pp | |
167 | By default, | |
168 | .Nm ls | |
169 | lists one entry per line to standard | |
170 | output; the exceptions are to terminals or when the | |
171 | .Fl C | |
172 | option is specified. | |
173 | .Pp | |
174 | File information is displayed with one or more | |
175 | <blank>s separating the information associated with the | |
176 | .Fl i , | |
177 | .Fl s , | |
178 | and | |
179 | .Fl l | |
180 | options. | |
181 | .Ss The Long Format | |
182 | If the | |
183 | .Fl l | |
184 | option is given, the following information | |
185 | is be displayed: | |
186 | file mode, | |
187 | number of links, owner name, | |
188 | .\" group name, | |
189 | number of bytes in the file, abbreviated | |
190 | month, day-of-month file was last modified, | |
191 | hour file last modified, minute file last | |
192 | modified, and the pathname. | |
193 | .Pp | |
194 | If the owner name is not a known user name | |
195 | the numeric ID is displayed. | |
196 | .Pp | |
197 | If the file is a character special or block special file, | |
198 | the major and minor device numbers for the file are displayed | |
199 | in the size field. If the file is a symbolic link the pathname of the | |
200 | linked-to file is preceded by | |
201 | .Dq \-> . | |
202 | .Pp | |
203 | The file mode printed under the -l option consists of the | |
204 | the entry type, owner permissions, and group permissions. | |
205 | The entry type character describes the type of file, as | |
206 | follows: | |
207 | .Pp | |
208 | .Bl -tag -width 4n -offset indent -compact | |
209 | .It Sy b | |
210 | Block special file. | |
211 | .It Sy c | |
212 | Character special file. | |
213 | .It Sy d | |
214 | Directory. | |
215 | .It Sy l | |
216 | Symbolic link. | |
217 | .It Sy s | |
218 | Socket link. | |
219 | .\" .It Sy p | |
220 | .\" .Tn FIFO . | |
221 | .It Sy \- | |
222 | Regular file. | |
223 | .El | |
224 | .Pp | |
225 | The next three fields | |
226 | are three characters each: | |
227 | owner permissions, | |
228 | group permissions, and | |
229 | other permissions. | |
230 | Each field has three character positions: | |
231 | .Bl -enum -offset indent | |
232 | .It | |
233 | If | |
234 | .Sy r , | |
235 | the file is readable; if | |
236 | .Sy \- , | |
237 | it is not readable. | |
238 | .It | |
239 | If | |
240 | .Sy w , | |
241 | the file is writable; if | |
242 | .Sy \- , | |
243 | it is not writable. | |
244 | .It | |
245 | The first of the following that applies: | |
246 | .Bl -tag -width 4n -offset indent | |
247 | .It Sy S | |
248 | If in the owner permissions, the file is not executable and | |
249 | set-user-ID mode is set. | |
250 | If in the group permissions, the file is not executable | |
251 | and set-group-ID mode is set. | |
252 | .It Sy s | |
253 | If in the owner permissions, the file is executable | |
254 | and set-user-ID mode is set. | |
255 | If in the group permissions, the file is executable | |
256 | and setgroup-ID mode is set. | |
257 | .It Sy x | |
258 | The file is executable or the directory is | |
259 | searchable. | |
260 | .It Sy \- | |
261 | The file is neither readable, writeable, exectutable, | |
262 | or set-user-ID or set-group-ID mode nor sticky. (See below.) | |
263 | .El | |
264 | .Pp | |
265 | These next two apply only to the third character in the last group | |
266 | (other permissions). | |
267 | .Bl -tag -width 4n -offset indent | |
268 | .It Sy T | |
269 | The sticky bit is set | |
270 | (mode | |
271 | .Li 1000 ) , | |
272 | but not execute or search permission. (See | |
273 | .Xr chmod 1 | |
274 | or | |
275 | .Xr sticky 8 . ) | |
276 | .It Sy t | |
277 | The sticky bit is set (mode | |
278 | .Li 1000 ) , | |
279 | and is searcheable or executable. | |
280 | (See | |
281 | .Xr chmod 1 | |
282 | or | |
283 | .Xr sticky 8 . ) | |
284 | .El | |
285 | .El | |
286 | .Pp | |
287 | The | |
288 | .Nm ls | |
289 | utility exits 0 on success, and >0 if an error occurs. | |
290 | .Sh ENVIRONMENT | |
291 | The following environment variables affect the execution of | |
292 | .Nm ls : | |
293 | .Bl -tag -width COLUMNS | |
294 | .It COLUMNS | |
295 | If this variable contains a string representing a | |
296 | decimal integer, it is used as the | |
297 | column position width for displaying | |
298 | multiple-text-column output. | |
299 | The | |
300 | .Nm ls | |
301 | utility calculates how | |
302 | many pathname text columns to display | |
303 | based on the width provided. | |
304 | (See | |
305 | .Fl C . ) | |
306 | .El | |
307 | .Sh SEE ALSO | |
308 | .Xr chmod 1 , | |
309 | .Xr sticky 8 | |
310 | .Sh HISTORY | |
311 | A | |
312 | .Nm ls | |
313 | command appeared in | |
314 | .At v6 . | |
315 | .\" .Sh STANDARDS | |
316 | .\" .The | |
317 | .\" .Nm ls | |
318 | .\" function is expected to be | |
319 | .\" .Tn POSIX | |
320 | .\" 1003.2 compatible. |