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 | .\" |
32980675 | 9 | .\" @(#)ls.1 6.19 (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. | |
59 | .\"and a vertical bar (|) after | |
60 | .\"each that is a | |
61 | .\".Tn FIFO . | |
62 | .It Fl L | |
30149789 KM |
63 | If argument is a symbolic link, list the file or directory the link references |
64 | rather than the link itself. | |
a93cea6a CL |
65 | .It Fl R |
66 | Recursively list subdirectories encountered. | |
67 | .It Fl T | |
e05a6377 KB |
68 | Display complete time information for the file, including |
69 | month, day, hour, minute, second, and year. | |
a93cea6a CL |
70 | .It Fl a |
71 | Include directory entries whose names begin with a | |
72 | dot (.). | |
73 | .It Fl c | |
74 | Use time when file status was last changed for sorting or printing. | |
75 | .It Fl d | |
76 | Directories are listed as plain files (not searched recursively). | |
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). | |
88 | .It Fl k | |
89 | Modifies the | |
90 | .Fl s | |
91 | option, causing the sizes to be reported in kilobytes. | |
92 | .It Fl l | |
93 | (The lowercase letter ``ell.'') List in long format. (See below.) | |
94 | If the output is to a terminal, a total sum for all the file | |
95 | sizes is output on a line before the long listing. | |
32980675 KM |
96 | .It Fl g |
97 | Include the file flags in a long | |
98 | .Pq Fl l | |
99 | output | |
a93cea6a CL |
100 | .It Fl q |
101 | Force printing of non-graphic characters in file names as | |
102 | the character `?'; this is the default when output is to a terminal. | |
103 | .It Fl r | |
104 | Reverse the order of the sort to get reverse | |
105 | lexicographical order or the oldest entries first. | |
106 | .It Fl s | |
107 | Display the number of file system bytes actually | |
108 | used by each file, in units of 512, where partial | |
109 | units are rounded up to the next integer value. | |
110 | If the output is to a terminal, a total sum for all the file | |
111 | sizes is output on a line before the listing. | |
112 | .It Fl t | |
113 | Sort by time modified (most recently modified | |
114 | first) before sorting the operands by lexicographical | |
115 | order. | |
116 | .It Fl u | |
117 | Use time of last access, | |
118 | instead of last modification | |
119 | of the file for sorting | |
120 | .Pq Fl t | |
121 | or printing | |
122 | .Pq Fl l . | |
123 | .It Fl \&1 | |
124 | (The numeric digit ``one.'') Force output to be | |
125 | one entry per line. | |
126 | This is the default when | |
127 | output is not to a terminal. | |
128 | .El | |
129 | .Pp | |
c699b55c | 130 | The |
a93cea6a CL |
131 | .Fl 1 , |
132 | .Fl C , | |
c699b55c | 133 | and |
a93cea6a | 134 | .Fl l |
c699b55c KB |
135 | options all override each other; the last one specified determines |
136 | the format used. | |
a93cea6a | 137 | .Pp |
c699b55c | 138 | The |
a93cea6a | 139 | .Fl c , |
c699b55c | 140 | and |
a93cea6a | 141 | .Fl u |
c699b55c KB |
142 | options override each other; the last one specified determines |
143 | the file time used. | |
a93cea6a CL |
144 | .Pp |
145 | By default, | |
146 | .Nm ls | |
147 | lists one entry per line to standard | |
148 | output; the exceptions are to terminals or when the | |
149 | .Fl C | |
150 | option is specified. | |
151 | .Pp | |
152 | File information is displayed with one or more | |
153 | <blank>s separating the information associated with the | |
154 | .Fl i , | |
155 | .Fl s , | |
156 | and | |
157 | .Fl l | |
158 | options. | |
159 | .Ss The Long Format | |
160 | If the | |
161 | .Fl l | |
162 | option is given, the following information | |
163 | is be displayed: | |
164 | file mode, | |
165 | number of links, owner name, | |
166 | .\" group name, | |
167 | number of bytes in the file, abbreviated | |
168 | month, day-of-month file was last modified, | |
169 | hour file last modified, minute file last | |
170 | modified, and the pathname. | |
171 | .Pp | |
172 | If the owner name is not a known user name | |
173 | the numeric ID is displayed. | |
174 | .Pp | |
175 | If the file is a character special or block special file, | |
176 | the major and minor device numbers for the file are displayed | |
177 | in the size field. If the file is a symbolic link the pathname of the | |
178 | linked-to file is preceded by | |
179 | .Dq \-> . | |
180 | .Pp | |
181 | The file mode printed under the -l option consists of the | |
182 | the entry type, owner permissions, and group permissions. | |
183 | The entry type character describes the type of file, as | |
184 | follows: | |
185 | .Pp | |
186 | .Bl -tag -width 4n -offset indent -compact | |
187 | .It Sy b | |
188 | Block special file. | |
189 | .It Sy c | |
190 | Character special file. | |
191 | .It Sy d | |
192 | Directory. | |
193 | .It Sy l | |
194 | Symbolic link. | |
195 | .It Sy s | |
196 | Socket link. | |
197 | .\" .It Sy p | |
198 | .\" .Tn FIFO . | |
199 | .It Sy \- | |
200 | Regular file. | |
201 | .El | |
202 | .Pp | |
203 | The next three fields | |
204 | are three characters each: | |
205 | owner permissions, | |
206 | group permissions, and | |
207 | other permissions. | |
208 | Each field has three character positions: | |
209 | .Bl -enum -offset indent | |
210 | .It | |
211 | If | |
212 | .Sy r , | |
213 | the file is readable; if | |
214 | .Sy \- , | |
215 | it is not readable. | |
216 | .It | |
217 | If | |
218 | .Sy w , | |
219 | the file is writable; if | |
220 | .Sy \- , | |
221 | it is not writable. | |
222 | .It | |
223 | The first of the following that applies: | |
224 | .Bl -tag -width 4n -offset indent | |
225 | .It Sy S | |
226 | If in the owner permissions, the file is not executable and | |
227 | set-user-ID mode is set. | |
228 | If in the group permissions, the file is not executable | |
229 | and set-group-ID mode is set. | |
230 | .It Sy s | |
231 | If in the owner permissions, the file is executable | |
232 | and set-user-ID mode is set. | |
233 | If in the group permissions, the file is executable | |
234 | and setgroup-ID mode is set. | |
235 | .It Sy x | |
236 | The file is executable or the directory is | |
237 | searchable. | |
238 | .It Sy \- | |
239 | The file is neither readable, writeable, exectutable, | |
240 | or set-user-ID or set-group-ID mode nor sticky. (See below.) | |
241 | .El | |
242 | .Pp | |
243 | These next two apply only to the third character in the last group | |
244 | (other permissions). | |
245 | .Bl -tag -width 4n -offset indent | |
246 | .It Sy T | |
247 | The sticky bit is set | |
248 | (mode | |
249 | .Li 1000 ) , | |
250 | but not execute or search permission. (See | |
251 | .Xr chmod 1 | |
252 | or | |
253 | .Xr sticky 8 . ) | |
254 | .It Sy t | |
255 | The sticky bit is set (mode | |
256 | .Li 1000 ) , | |
257 | and is searcheable or executable. | |
258 | (See | |
259 | .Xr chmod 1 | |
260 | or | |
261 | .Xr sticky 8 . ) | |
262 | .El | |
263 | .El | |
264 | .Pp | |
265 | The | |
266 | .Nm ls | |
267 | utility exits 0 on success, and >0 if an error occurs. | |
268 | .Sh ENVIRONMENT | |
269 | The following environment variables affect the execution of | |
270 | .Nm ls : | |
271 | .Bl -tag -width COLUMNS | |
272 | .It COLUMNS | |
273 | If this variable contains a string representing a | |
274 | decimal integer, it is used as the | |
275 | column position width for displaying | |
276 | multiple-text-column output. | |
277 | The | |
278 | .Nm ls | |
279 | utility calculates how | |
280 | many pathname text columns to display | |
281 | based on the width provided. | |
282 | (See | |
283 | .Fl C . ) | |
284 | .El | |
285 | .Sh SEE ALSO | |
286 | .Xr chmod 1 , | |
287 | .Xr sticky 8 | |
288 | .Sh HISTORY | |
289 | A | |
290 | .Nm ls | |
291 | command appeared in | |
292 | .At v6 . | |
293 | .\" .Sh STANDARDS | |
294 | .\" .The | |
295 | .\" .Nm ls | |
296 | .\" function is expected to be | |
297 | .\" .Tn POSIX | |
298 | .\" 1003.2 compatible. |