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 | .\" | |
9d5fbfa8 | 5 | .\" @(#)ls.1 6.11 (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 | [ | |
9d5fbfa8 | 14 | .B \-1AaCcdFfgikLlqRrstu |
c699b55c | 15 | ] [ file ... ] |
a10206cc | 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 | |
c699b55c | 31 | The options are as follows: |
a10206cc | 32 | .TP |
c699b55c KB |
33 | .B \-1 |
34 | force one entry per line output format; this is the default when | |
35 | output is not to a terminal. | |
a10206cc | 36 | .TP |
c699b55c KB |
37 | .B \-A |
38 | List all entries except for ``.'' and ``..''. | |
39 | Always set for the super-user. | |
a10206cc | 40 | .TP |
30149789 KM |
41 | .B \-a |
42 | List all entries; in the absence of this option, entries whose | |
43 | names begin with a period | |
44 | .RB ( . ) | |
45 | are | |
46 | .I not | |
47 | listed. | |
a10206cc | 48 | .TP |
c699b55c KB |
49 | .B \-C |
50 | force multi-column output; this is the default when output is to a terminal. | |
0a413117 | 51 | .TP |
c699b55c KB |
52 | .B \-c |
53 | Use time when file status was last changed for sorting or printing. | |
a10206cc | 54 | .TP |
30149789 KM |
55 | .B \-d |
56 | If argument is a directory, list only its name; | |
57 | often used with \fB\-l\fR to get the status of a directory. | |
58 | .TP | |
9d5fbfa8 KB |
59 | .B \-f |
60 | Don't sort the output. | |
61 | .TP | |
c699b55c KB |
62 | .B \-F |
63 | cause directories to be marked with a trailing `/', | |
64 | sockets with a trailing `=', | |
65 | symbolic links with a trailing `@', and executable | |
66 | files with a trailing `*'. | |
67 | .TP | |
68 | .B \-g | |
69 | Include the group ownership of the file in a long output. | |
70 | .TP | |
71 | .B \-i | |
72 | For each file, print the i-number in the first column of the report. | |
73 | .TP | |
74 | .B -k | |
75 | Modifies the | |
76 | .I -s | |
77 | option, causing the sizes to be reported in kilobytes. | |
78 | .TP | |
30149789 KM |
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 |
c699b55c KB |
83 | .B \-l |
84 | List in long format, giving mode, number of links, owner, | |
85 | size in bytes, and time of last modification for each file. | |
86 | (See below.) | |
87 | If the file is a special file the size field will instead contain | |
88 | the major and minor device numbers. | |
89 | If the file is a symbolic link the pathname of | |
90 | the linked-to file is printed preceded by ``\->''. | |
91 | .TP | |
92 | .B \-q | |
93 | force printing of non-graphic characters in file names as | |
94 | the character `?'; this is the default when output is to a terminal. | |
95 | .TP | |
96 | .B \-R | |
97 | recursively list subdirectories encountered. | |
98 | .TP | |
30149789 | 99 | .B \-r |
ccc80378 MK |
100 | Reverse the order of sort to get reverse alphabetic |
101 | or oldest first as appropriate. | |
a10206cc | 102 | .TP |
c699b55c KB |
103 | .B \-s |
104 | Display the sizes of files and directories in 512-byte blocks. | |
105 | .TP | |
106 | .B \-t | |
107 | Sort by time modified (latest first) instead of | |
108 | by name. | |
109 | .TP | |
30149789 | 110 | .B \-u |
a10206cc KM |
111 | Use time of last access instead of last |
112 | modification for sorting | |
30149789 KM |
113 | (with the \fB\-t\fP option) |
114 | and/or printing (with the \fB\-l\fP option). | |
c699b55c KB |
115 | .PP |
116 | The | |
117 | .IR -1 , | |
118 | .IR -C , | |
119 | and | |
120 | .I -l | |
121 | options all override each other; the last one specified determines | |
122 | the format used. | |
123 | .PP | |
124 | The | |
125 | .IR -c , | |
126 | and | |
127 | .I -u | |
128 | options override each other; the last one specified determines | |
129 | the file time used. | |
a10206cc KM |
130 | .PP |
131 | The mode printed under the | |
132 | .B \-l | |
133 | option contains 11 characters | |
134 | which are interpreted | |
135 | as follows: | |
136 | the first character is | |
137 | .TP 3 | |
30149789 | 138 | .B d |
a10206cc KM |
139 | if the entry is a directory; |
140 | .br | |
141 | .ns | |
142 | .TP 3 | |
30149789 | 143 | .B b |
a10206cc KM |
144 | if the entry is a block-type special file; |
145 | .br | |
146 | .ns | |
147 | .TP 3 | |
30149789 | 148 | .B c |
a10206cc KM |
149 | if the entry is a character-type special file; |
150 | .br | |
151 | .ns | |
152 | .TP 3 | |
30149789 KM |
153 | .B l |
154 | if the entry is a symbolic link; | |
155 | .br | |
156 | .ns | |
157 | .TP | |
158 | .B s | |
159 | if the entry is a socket, or | |
a10206cc KM |
160 | .br |
161 | .ns | |
162 | .TP 3 | |
163 | .B \- | |
164 | if the entry is a plain file. | |
165 | .PP | |
166 | The next 9 characters are interpreted | |
167 | as three sets of three bits each. | |
168 | The first set refers to owner permissions; | |
adbdb3c0 | 169 | the next refers to permissions to others in the same user-group; |
a10206cc KM |
170 | and the last to all others. |
171 | Within each set the three characters indicate | |
172 | permission respectively to read, to write, or to | |
173 | execute the file as a program. | |
174 | For a directory, `execute' permission is interpreted | |
30149789 | 175 | to mean permission to search the directory. |
a10206cc KM |
176 | The permissions are indicated as follows: |
177 | .TP 3 | |
178 | .B r | |
179 | if the file is readable; | |
180 | .br | |
181 | .ns | |
182 | .TP 3 | |
183 | .B w | |
184 | if the file is writable; | |
185 | .br | |
186 | .ns | |
187 | .TP 3 | |
188 | .B x | |
189 | if the file is executable; | |
190 | .br | |
191 | .ns | |
192 | .TP 3 | |
193 | .B \- | |
194 | if the indicated permission is not granted. | |
195 | .PP | |
303dbd7d KB |
196 | The group-execute permission character is given as \fBs\fP if the file has |
197 | the set-group-id bit set; likewise the user-execute permission character is | |
198 | given as \fBs\fP if the file has the set-user-id bit set. These are given | |
199 | as \fBS\fP (capitalized) if the corresponding execute permission is NOT | |
200 | set. | |
a10206cc KM |
201 | .PP |
202 | The last character of the mode (normally `x' or `\-') is | |
203 | .B t | |
204 | if the 1000 bit of the mode is on. | |
205 | See | |
206 | .IR chmod (1) | |
c699b55c KB |
207 | for the meaning of this mode. This is given as |
208 | .B T | |
209 | (capitalized) if the corresponding execute permission is NOT set. | |
a10206cc KM |
210 | .PP |
211 | When the sizes of the files in a directory | |
212 | are listed, a total count of blocks, | |
213 | including indirect blocks is printed. | |
214 | .SH FILES | |
30149789 | 215 | /etc/passwd to get user id's for |
a10206cc KM |
216 | `ls \-l'. |
217 | .br | |
30149789 | 218 | /etc/group to get group id's for |
a10206cc KM |
219 | `ls \-g'. |
220 | .SH BUGS | |
a10206cc KM |
221 | The option setting based on whether the output is a teletype is |
222 | undesirable as ``ls\ \-s'' is much different than ``ls\ \-s\ |\ lpr''. | |
223 | On the other hand, not doing this setting would make old shell scripts | |
224 | which used | |
225 | .I ls | |
226 | almost certain losers. |