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