1chown(1) User Commands chown(1)
2
3
4
6 chown - change file ownership
7
9 /usr/bin/chown
10 /usr/bin/chown [-fhR] owner[:group] file...
11
12
13 /usr/bin/chown -s [-fhR] ownersid[:groupsid] file...
14
15
16 /usr/bin/chown -R [-f] [-H | -L | -P] owner[:group] file...
17
18
19 /usr/bin/chown -s -R [-f] [-H | -L | -P] ownersid[:groupsid] file...
20
21
22 /usr/xpg4/bin/chown
23 /usr/xpg4/bin/chown [-fhR] owner[:group] file...
24
25
26 /usr/xpg4/bin/chown -s [-fhR] ownersid[:groupsid] file...
27
28
29 /usr/xpg4/bin/chown -R [-f] [-H | -L | -P] owner[:group] file...
30
31
32 /usr/xpg4/bin/chown -s -R [-f] [-H | -L | -P] ownersid[:groupsid] file...
33
34
35 ksh93
36 chown [-cflhmnvHLPRX] [-r file] owner[:group] file...
37
38
40 /usr/bin/chown and /usr/xpg4/bin/chown
41 The chown utility sets the user ID of the file named by each file to
42 the user ID specified by owner, and, optionally, sets the group ID to
43 that specified by group.
44
45
46 If chown is invoked by other than the super-user, the set-user-ID bit
47 is cleared.
48
49
50 Only the owner of a file (or the super-user) can change the owner of
51 that file.
52
53
54 The operating system has a configuration option
55 {_POSIX_CHOWN_RESTRICTED}, to restrict ownership changes. When this
56 option is in effect the owner of the file is prevented from changing
57 the owner ID of the file. Only the super-user can arbitrarily change
58 owner IDs whether or not this option is in effect. To set this configu‐
59 ration option, include the following line in /etc/system:
60
61 set rstchown = 1
62
63
64
65
66 To disable this option, include the following line in /etc/system:
67
68 set rstchown = 0
69
70
71
72
73 {_POSIX_CHOWN_RESTRICTED} is enabled by default. See system(4) and
74 fpathconf(2).
75
76 ksh93
77 The chown built-in in ksh93 is associated with the /bin and /usr/bin
78 paths. It is invoked when chown is executed without a pathname prefix
79 and the pathname search finds a /bin/chown or /usr/bin/chown exe‐
80 cutable.
81
82
83 chown changes the ownership of each file to owner. owner can be speci‐
84 fied as either a user name or a numeric user id. The group ownership of
85 each file can also be changed to group by appending :group to the user
86 name.
87
89 /usr/bin/chown and /usr/xpg4/bin/chown
90 The following options are supported:
91
92 -f Force. Does not report errors.
93
94
95 -h If the file is a symbolic link, this option changes the owner of
96 the symbolic link. Without this option, the owner of the file
97 referenced by the symbolic link is changed.
98
99
100 -H If the file specified on the command line is a symbolic link ref‐
101 erencing a file of type directory, this option changes the owner
102 of the directory referenced by the symbolic link and all the
103 files in the file hierarchy below it. If a symbolic link is
104 encountered when traversing a file hierarchy, the owner of the
105 target file is changed, but no recursion takes place.
106
107
108 -L If the file is a symbolic link, this option changes the owner of
109 the file referenced by the symbolic link. If the file specified
110 on the command line, or encountered during the traversal of the
111 file hierarchy, is a symbolic link referencing a file of type
112 directory, then this option changes the owner of the directory
113 referenced by the symbolic link and all files in the file hierar‐
114 chy below it.
115
116
117 -P If the file specified on the command line or encountered during
118 the traversal of a file hierarchy is a symbolic link, this option
119 changes the owner of the symbolic link. This option does not fol‐
120 low the symbolic link to any other part of the file hierarchy.
121
122
123 -s The owner and/or group arguments are Windows SID strings. This
124 option requires a file system that supports storing SIDs, such as
125 ZFS.
126
127
128
129 Specifying more than one of the mutually-exclusive options -H, -L, or
130 -P is not considered an error. The last option specified determines the
131 behavior of chown.
132
133 /usr/bin/chown
134 The following options are supported:
135
136 -R Recursive. chown descends through the directory, and any subdi‐
137 rectories, setting the specified ownership ID as it proceeds.
138 When a symbolic link is encountered, the owner of the target file
139 is changed, unless the -h or -P option is specified. However, no
140 recursion takes place, unless the -H or -L option is specified.
141
142
143 /usr/xpg4/bin/chown
144 The following options are supported:
145
146 -R Recursive. chown descends through the directory, and any subdi‐
147 rectories, setting the specified ownership ID as it proceeds.
148 When a symbolic link is encountered, the owner of the target file
149 is changed, unless the -h or -P option is specified. Unless the
150 -H, -L, or -P option is specified, the -L option is used as the
151 default mode.
152
153
154 ksh93
155 The following options are supported by the ksh93 built-in chown com‐
156 mand:
157
158 -c
159 --changes
160
161 Describe only files whose ownership actually changes.
162
163
164 -f
165 --quiet | silent
166
167 Do not report files whose ownership fails to change.
168
169
170 -l | h
171 --symlink
172
173 Change the ownership of the symbolic links on systems that support
174 this option.
175
176
177 -m
178 --map
179
180 Interpret the first operand as a file that contains a map of:
181
182 from_uid:from_gid to_uid:to_gid
183
184
185 pairs. Ownership of files matching the from part of any pair is
186 changed to the corresponding to part of the pair. The process stops
187 at the first match for each file. Unmatched files are silently
188 ignored.
189
190
191 -n
192 --show
193
194 Show actions but do not execute.
195
196
197 -r
198 --reference=file
199
200 Omit the explicit ownership operand and use the ownership of the
201 file instead.
202
203
204 -v
205 --verbose
206
207 Describe the changed permissions of all files.
208
209
210 -H
211 --metaphysical
212
213 Follow symbolic links for command arguments. Otherwise do not fol‐
214 low symbolic links when traversing directories.
215
216
217 -L
218 --logical | follow
219
220 Follow symbolic links when traversing directories.
221
222
223 -P
224 --physical | nofollow
225
226 Do not follow symbolic links when traversing directories.
227
228
229 -R
230 --recursive
231
232 Recursively change ownership of directories and their contents.
233
234
235 -X
236 --test
237
238 Canonicalize output for testing.
239
240
242 The following operands are supported:
243
244 owner[:group] A user ID and optional group ID to be assigned to
245 file. The owner portion of this operand must be a user
246 name from the user database or a numeric user ID.
247 Either specifies a user ID to be given to each file
248 named by file. If a numeric owner exists in the user
249 database as a user name, the user ID number associated
250 with that user name is used as the user ID. Similarly,
251 if the group portion of this operand is present, it
252 must be a group name from the group database or a
253 numeric group ID. Either specifies a group ID to be
254 given to each file. If a numeric group operand exists
255 in the group database as a group name, the group ID
256 number associated with that group name is used as the
257 group ID.
258
259
260 file A path name of a file whose user ID is to be modified.
261
262
264 See largefile(5) for the description of the behavior of chown when
265 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
266
268 Example 1 Changing Ownership of All Files in the Hierarchy
269
270
271 The following command changes ownership of all files in the hierarchy,
272 including symbolic links, but not the targets of the links:
273
274
275 example% chown −R −h owner[:group] file...
276
277
278
280 See environ(5) for descriptions of the following environment variables
281 that affect the execution of chown: LANG, LC_ALL, LC_CTYPE, LC_MES‐
282 SAGES, and NLSPATH.
283
285 The following exit values are returned:
286
287 0 The utility executed successfully and all requested changes were
288 made.
289
290
291 >0 An error occurred.
292
293
295 /etc/passwd System password file
296
297
299 See attributes(5) for descriptions of the following attributes:
300
301 /usr/bin/chown
302 ┌─────────────────────────────┬─────────────────────────────┐
303 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
304 ├─────────────────────────────┼─────────────────────────────┤
305 │Availability │SUNWcsu │
306 ├─────────────────────────────┼─────────────────────────────┤
307 │CSI │Enabled. See NOTES. │
308 ├─────────────────────────────┼─────────────────────────────┤
309 │Interface Stability │Committed │
310 ├─────────────────────────────┼─────────────────────────────┤
311 │Standard │See standards(5). │
312 └─────────────────────────────┴─────────────────────────────┘
313
314 /usr/xpg4/bin/chown
315 ┌─────────────────────────────┬─────────────────────────────┐
316 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
317 ├─────────────────────────────┼─────────────────────────────┤
318 │Availability │SUNWxcu4 │
319 ├─────────────────────────────┼─────────────────────────────┤
320 │CSI │Enabled. See NOTES. │
321 ├─────────────────────────────┼─────────────────────────────┤
322 │Interface Stability │Committed │
323 ├─────────────────────────────┼─────────────────────────────┤
324 │Standard │See standards(5). │
325 └─────────────────────────────┴─────────────────────────────┘
326
327 ksh93
328 ┌─────────────────────────────┬─────────────────────────────┐
329 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
330 ├─────────────────────────────┼─────────────────────────────┤
331 │Availability │SUNWcsu │
332 ├─────────────────────────────┼─────────────────────────────┤
333 │Interface Stability │See below. │
334 └─────────────────────────────┴─────────────────────────────┘
335
336
337 The ksh93 built-in binding to /bin and /usr/bin is Volatile. The built-
338 in interfaces are Uncommitted.
339
341 chgrp(1), chmod(1),ksh93(1), chown(2), fpathconf(2), passwd(4), sys‐
342 tem(4), attributes(5), environ(5), largefile(5), standards(5)
343
345 chown is CSI-enabled except for the owner and group names.
346
347
348
349SunOS 5.11 11 Jul 2008 chown(1)