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

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       chown - change the file ownership
13

SYNOPSIS

15       chown [-hR] owner[:group] file ...
16
17       chown -R [-H | -L | -P ] owner[:group] file ...
18
19

DESCRIPTION

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

OPTIONS

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

OPERANDS

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

STDIN

114       Not used.
115

INPUT FILES

117       None.
118

ENVIRONMENT VARIABLES

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

ASYNCHRONOUS EVENTS

147       Default.
148

STDOUT

150       Not used.
151

STDERR

153       The standard error shall be used only for diagnostic messages.
154

OUTPUT FILES

156       None.
157

EXTENDED DESCRIPTION

159       None.
160

EXIT STATUS

162       The following exit values shall be returned:
163
164        0     The utility executed successfully and all requested changes were
165              made.
166
167       >0     An error occurred.
168
169

CONSEQUENCES OF ERRORS

171       Default.
172
173       The following sections are informative.
174

APPLICATION USAGE

176       Only the owner of a file or the user with  appropriate  privileges  may
177       change the owner or group of a file.
178
179       Some implementations restrict the use of chown to a user with appropri‐
180       ate privileges.
181

EXAMPLES

183       None.
184

RATIONALE

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

FUTURE DIRECTIONS

230       None.
231

SEE ALSO

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