1CHOWN(P)                   POSIX Programmer's Manual                  CHOWN(P)
2
3
4

NAME

6       chown - change the file ownership
7

SYNOPSIS

9       chown [-hR] owner[:group] file ...
10
11       chown -R [-H | -L | -P ] owner[:group] file ...
12
13

DESCRIPTION

15       The  chown utility shall set the user ID of the file named by each file
16       operand to the user ID specified by the owner operand.
17
18       For each file operand, or, if the -R option is used, each file  encoun‐
19       tered while walking the directory trees specified by the file operands,
20       the chown utility shall perform actions equivalent to the chown() func‐
21       tion  defined  in the System Interfaces volume of IEEE Std 1003.1-2001,
22       called with the following arguments:
23
24        1. The file operand shall be used as the path argument.
25
26        2. The user ID indicated by the owner portion  of  the  first  operand
27           shall be used as the owner argument.
28
29        3. If  the  group  portion of the first operand is given, the group ID
30           indicated by it shall be used as the group argument; otherwise, the
31           group ownership shall not be changed.
32
33       Unless  chown  is invoked by a process with appropriate privileges, the
34       set-user-ID and set-group-ID bits of a regular file  shall  be  cleared
35       upon  successful  completion;  the set-user-ID and set-group-ID bits of
36       other file types may be cleared.
37

OPTIONS

39       The chown utility shall conform  to  the  Base  Definitions  volume  of
40       IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
41
42       The following options shall be supported by the implementation:
43
44       -h     If  the  system  supports  user IDs for symbolic links, for each
45              file operand that names a file  of  type  symbolic  link,  chown
46              shall  attempt  to set the user ID of the symbolic link.  If the
47              system supports group IDs for symbolic links, and a group ID was
48              specified,  for each file operand that names a file of type sym‐
49              bolic link, chown shall attempt to set the group ID of the  sym‐
50              bolic link. If the system does not support user or group IDs for
51              symbolic links, for each file operand that names a file of  type
52              symbolic link, chown shall do nothing more with the current file
53              and shall go on to any remaining files.
54
55       -H     If the -R option is specified and a symbolic link referencing  a
56              file  of  type directory is specified on the command line, chown
57              shall change the user ID (and group ID,  if  specified)  of  the
58              directory  referenced  by the symbolic link and all files in the
59              file hierarchy below it.
60
61       -L     If the -R option is specified and a symbolic link referencing  a
62              file  of  type  directory  is  specified  on the command line or
63              encountered during the traversal  of  a  file  hierarchy,  chown
64              shall  change  the  user  ID (and group ID, if specified) of the
65              directory referenced by the symbolic link and all files  in  the
66              file hierarchy below it.
67
68       -P     If  the  -R option is specified and a symbolic link is specified
69              on the command line or encountered during  the  traversal  of  a
70              file  hierarchy,  chown shall change the owner ID (and group ID,
71              if specified) of the symbolic link if the system  supports  this
72              operation.  The chown utility shall not follow the symbolic link
73              to any other part of the file hierarchy.
74
75       -R     Recursively change file user and group IDs. For each file  oper‐
76              and  that names a directory, chown shall change the user ID (and
77              group ID, if specified) of the directory and all  files  in  the
78              file hierarchy below it. Unless a -H, -L, or -P option is speci‐
79              fied, it is unspecified which of these options will be  used  as
80              the default.
81
82
83       Specifying  more than one of the mutually-exclusive options -H, -L, and
84       -P shall not be considered an error.  The last option  specified  shall
85       determine the behavior of the utility.
86

OPERANDS

88       The following operands shall be supported:
89
90       owner[:group]
91              A  user  ID  and  optional  group ID to be assigned to file. The
92              owner portion of this operand shall be a user name from the user
93              database  or a numeric user ID. Either specifies a user ID which
94              shall be given to each file named by one of the  file  operands.
95              If a numeric owner operand exists in the user database as a user
96              name, the user ID number associated with that user name shall be
97              used as the user ID. Similarly, if the group portion of this op‐
98              erand is present, it shall be a group name from the group  data‐
99              base  or  a  numeric group ID. Either specifies a group ID which
100              shall be given to each file. If a numeric group  operand  exists
101              in the group database as a group name, the group ID number asso‐
102              ciated with that group name shall be used as the group ID.
103
104       file   A pathname of a file whose user ID is to be modified.
105
106

STDIN

108       Not used.
109

INPUT FILES

111       None.
112

ENVIRONMENT VARIABLES

114       The following environment  variables  shall  affect  the  execution  of
115       chown:
116
117       LANG   Provide  a  default value for the internationalization variables
118              that are unset or null. (See  the  Base  Definitions  volume  of
119              IEEE Std 1003.1-2001,  Section  8.2,  Internationalization Vari‐
120              ables for the precedence of internationalization variables  used
121              to determine the values of locale categories.)
122
123       LC_ALL If  set  to a non-empty string value, override the values of all
124              the other internationalization variables.
125
126       LC_CTYPE
127              Determine the locale for  the  interpretation  of  sequences  of
128              bytes  of  text  data as characters (for example, single-byte as
129              opposed to multi-byte characters in arguments).
130
131       LC_MESSAGES
132              Determine the locale that should be used to  affect  the  format
133              and contents of diagnostic messages written to standard error.
134
135       NLSPATH
136              Determine the location of message catalogs for the processing of
137              LC_MESSAGES .
138
139

ASYNCHRONOUS EVENTS

141       Default.
142

STDOUT

144       Not used.
145

STDERR

147       The standard error shall be used only for diagnostic messages.
148

OUTPUT FILES

150       None.
151

EXTENDED DESCRIPTION

153       None.
154

EXIT STATUS

156       The following exit values shall be returned:
157
158        0     The utility executed successfully and all requested changes were
159              made.
160
161       >0     An error occurred.
162
163

CONSEQUENCES OF ERRORS

165       Default.
166
167       The following sections are informative.
168

APPLICATION USAGE

170       Only  the  owner  of a file or the user with appropriate privileges may
171       change the owner or group of a file.
172
173       Some implementations restrict the use of chown to a user with appropri‐
174       ate privileges.
175

EXAMPLES

177       None.
178

RATIONALE

180       The  System  V  and  BSD versions use different exit status codes. Some
181       implementations used the exit status as a count of the number of errors
182       that  occurred;  this  practice is unworkable since it can overflow the
183       range of valid exit status values. These are masked by specifying  only
184       0 and >0 as exit values.
185
186       The  functionality  of  chown is described substantially through refer‐
187       ences   to   functions   in   the   System   Interfaces    volume    of
188       IEEE Std 1003.1-2001.  In  this  way, there is no duplication of effort
189       required for  describing  the  interactions  of  permissions,  multiple
190       groups, and so on.
191
192       The  4.3  BSD method of specifying both owner and group was included in
193       this volume of IEEE Std 1003.1-2001 because:
194
195        * There are cases  where  the  desired  end  condition  could  not  be
196          achieved  using  the chgrp and chown (that only changed the user ID)
197          utilities. (If the current owner is not  a  member  of  the  desired
198          group  and  the  desired owner is not a member of the current group,
199          the chown() function could fail unless  both  owner  and  group  are
200          changed at the same time.)
201
202        * Even if they could be changed independently, in cases where both are
203          being changed, there is a 100% performance penalty caused  by  being
204          forced to invoke both utilities.
205
206       The  BSD syntax user[. group] was changed to user[: group] in this vol‐
207       ume of IEEE Std 1003.1-2001 because the period is a valid character  in
208       login   names   (as   specified  by  the  Base  Definitions  volume  of
209       IEEE Std 1003.1-2001, login names consist of characters in the portable
210       filename character set). The colon character was chosen as the replace‐
211       ment for the period character because it would never be  allowed  as  a
212       character in a user name or group name on historical implementations.
213
214       The  -R option is considered by some observers as an undesirable depar‐
215       ture from the historical UNIX system  tools  approach;  since  a  tool,
216       find, already exists to recurse over directories, there seemed to be no
217       good reason to require other tools to have to duplicate that  function‐
218       ality.   However,  the  -R  option  was deemed an important user conve‐
219       nience, is far more efficient than forking a separate process for  each
220       element  of  the  directory  hierarchy, and is in widespread historical
221       use.
222

FUTURE DIRECTIONS

224       None.
225

SEE ALSO

227       chmod , chgrp , the System Interfaces volume  of  IEEE Std 1003.1-2001,
228       chown()
229
231       Portions  of  this text are reprinted and reproduced in electronic form
232       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
233       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
234       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
235       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
236       event of any discrepancy between this version and the original IEEE and
237       The  Open Group Standard, the original IEEE and The Open Group Standard
238       is the referee document. The original Standard can be  obtained  online
239       at http://www.opengroup.org/unix/online.html .
240
241
242
243IEEE/The Open Group                  2003                             CHOWN(P)
Impressum