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