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 | .\" | |
7f5a7d0f | 5 | .\" @(#)ls.1 6.2 (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 | [ | |
7f5a7d0f | 14 | .B \-acdfgilqrstu1ACLFRS |
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 |
7f5a7d0f JB |
50 | .B \-S |
51 | Sort by size (biggest first) instead of | |
52 | by name. | |
53 | This option turns on | |
54 | .BR \-s . | |
55 | If both | |
56 | .B \-t | |
57 | and | |
58 | .B \-S | |
59 | are given, | |
60 | .B \-t | |
61 | overrides | |
62 | (e.g. sorting is done by time). | |
63 | .TP | |
30149789 KM |
64 | .B \-a |
65 | List all entries; in the absence of this option, entries whose | |
66 | names begin with a period | |
67 | .RB ( . ) | |
68 | are | |
69 | .I not | |
70 | listed. | |
a10206cc | 71 | .TP |
30149789 KM |
72 | .B \-s |
73 | Give size in kilobytes of each file. | |
a10206cc | 74 | .TP |
30149789 KM |
75 | .B \-d |
76 | If argument is a directory, list only its name; | |
77 | often used with \fB\-l\fR to get the status of a directory. | |
78 | .TP | |
79 | .B \-L | |
80 | If argument is a symbolic link, list the file or directory the link references | |
81 | rather than the link itself. | |
a10206cc | 82 | .TP |
30149789 | 83 | .B \-r |
7f5a7d0f JB |
84 | Reverse the order of sort to get reverse alphabetic, |
85 | size, or oldest first as appropriate. | |
a10206cc | 86 | .TP |
30149789 | 87 | .B \-u |
a10206cc KM |
88 | Use time of last access instead of last |
89 | modification for sorting | |
30149789 KM |
90 | (with the \fB\-t\fP option) |
91 | and/or printing (with the \fB\-l\fP option). | |
a10206cc | 92 | .TP |
30149789 | 93 | .B \-c |
a10206cc KM |
94 | Use time of file creation for sorting or printing. |
95 | .TP | |
30149789 KM |
96 | .B \-i |
97 | For each file, print the i-number in the first column of the report. | |
a10206cc | 98 | .TP |
30149789 | 99 | .B \-f |
a10206cc KM |
100 | Force each argument to be interpreted as a directory |
101 | and list the name found in each slot. | |
102 | This option turns off | |
7f5a7d0f | 103 | .B "\-t, \-S," |
a10206cc KM |
104 | and |
105 | .B \-r, | |
106 | and | |
107 | turns on | |
108 | .B \-a; | |
109 | the order is the order in which entries | |
110 | appear in the directory. | |
111 | .TP | |
30149789 KM |
112 | .B \-F |
113 | cause directories to be marked with a trailing `/', | |
114 | sockets with a trailing `=', | |
115 | symbolic links with a trailing `@', and executable | |
116 | files with a trailing `*'. | |
a10206cc | 117 | .TP |
30149789 KM |
118 | .B \-R |
119 | recursively list subdirectories encountered. | |
a10206cc | 120 | .TP |
30149789 KM |
121 | .B \-1 |
122 | force one entry per line output format; this is the default when | |
123 | output is not to a terminal. | |
a10206cc | 124 | .TP |
30149789 KM |
125 | .B \-C |
126 | force multi-column output; this is the default when output is to a terminal. | |
a10206cc | 127 | .TP |
30149789 | 128 | .B \-q |
a10206cc | 129 | force printing of non-graphic characters in file names as |
30149789 | 130 | the character `?'; this is the default when output is to a terminal. |
a10206cc KM |
131 | .PP |
132 | The mode printed under the | |
133 | .B \-l | |
134 | option contains 11 characters | |
135 | which are interpreted | |
136 | as follows: | |
137 | the first character is | |
138 | .TP 3 | |
30149789 | 139 | .B d |
a10206cc KM |
140 | if the entry is a directory; |
141 | .br | |
142 | .ns | |
143 | .TP 3 | |
30149789 | 144 | .B b |
a10206cc KM |
145 | if the entry is a block-type special file; |
146 | .br | |
147 | .ns | |
148 | .TP 3 | |
30149789 | 149 | .B c |
a10206cc KM |
150 | if the entry is a character-type special file; |
151 | .br | |
152 | .ns | |
153 | .TP 3 | |
30149789 KM |
154 | .B l |
155 | if the entry is a symbolic link; | |
156 | .br | |
157 | .ns | |
158 | .TP | |
159 | .B s | |
160 | if the entry is a socket, or | |
a10206cc KM |
161 | .br |
162 | .ns | |
163 | .TP 3 | |
164 | .B \- | |
165 | if the entry is a plain file. | |
166 | .PP | |
167 | The next 9 characters are interpreted | |
168 | as three sets of three bits each. | |
169 | The first set refers to owner permissions; | |
170 | the next to permissions to others in the same user-group; | |
171 | and the last to all others. | |
172 | Within each set the three characters indicate | |
173 | permission respectively to read, to write, or to | |
174 | execute the file as a program. | |
175 | For a directory, `execute' permission is interpreted | |
30149789 | 176 | to mean permission to search the directory. |
a10206cc KM |
177 | The permissions are indicated as follows: |
178 | .TP 3 | |
179 | .B r | |
180 | if the file is readable; | |
181 | .br | |
182 | .ns | |
183 | .TP 3 | |
184 | .B w | |
185 | if the file is writable; | |
186 | .br | |
187 | .ns | |
188 | .TP 3 | |
189 | .B x | |
190 | if the file is executable; | |
191 | .br | |
192 | .ns | |
193 | .TP 3 | |
194 | .B \- | |
195 | if the indicated permission is not granted. | |
196 | .PP | |
197 | The group-execute permission character is given | |
198 | as | |
199 | .B s | |
30149789 | 200 | if the file has the set-group-id bit set; |
a10206cc KM |
201 | likewise the user-execute permission character is given |
202 | as | |
203 | .B s | |
30149789 | 204 | if the file has the set-user-id bit set. |
a10206cc KM |
205 | .PP |
206 | The last character of the mode (normally `x' or `\-') is | |
207 | .B t | |
208 | if the 1000 bit of the mode is on. | |
209 | See | |
210 | .IR chmod (1) | |
211 | for the meaning of this mode. | |
212 | .PP | |
213 | When the sizes of the files in a directory | |
214 | are listed, a total count of blocks, | |
215 | including indirect blocks is printed. | |
216 | .SH FILES | |
30149789 | 217 | /etc/passwd to get user id's for |
a10206cc KM |
218 | `ls \-l'. |
219 | .br | |
30149789 | 220 | /etc/group to get group id's for |
a10206cc KM |
221 | `ls \-g'. |
222 | .SH BUGS | |
223 | Newline and tab are considered printing characters in file names. | |
224 | .PP | |
225 | The output device is assumed to be 80 columns wide. | |
226 | .PP | |
227 | The option setting based on whether the output is a teletype is | |
228 | undesirable as ``ls\ \-s'' is much different than ``ls\ \-s\ |\ lpr''. | |
229 | On the other hand, not doing this setting would make old shell scripts | |
230 | which used | |
231 | .I ls | |
232 | almost certain losers. |