1CHGRP(1P) POSIX Programmer's Manual CHGRP(1P)
2
3
4
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
12 chgrp — change the file group ownership
13
15 chgrp [-h] group file...
16
17 chgrp -R [-H|-L|-P] group file...
18
20 The chgrp utility shall set the group ID of the file named by each file
21 operand to the group ID specified by the group operand.
22
23 For each file operand, or, if the -R option is used, each file encoun‐
24 tered while walking the directory trees specified by the file operands,
25 the chgrp utility shall perform actions equivalent to the chown() func‐
26 tion defined in the System Interfaces volume of POSIX.1‐2017, called
27 with the following arguments:
28
29 * The file operand shall be used as the path argument.
30
31 * The user ID of the file shall be used as the owner argument.
32
33 * The specified group ID shall be used as the group argument.
34
35 Unless chgrp is invoked by a process with appropriate privileges, the
36 set-user-ID and set-group-ID bits of a regular file shall be cleared
37 upon successful completion; the set-user-ID and set-group-ID bits of
38 other file types may be cleared.
39
41 The chgrp utility shall conform to the Base Definitions volume of
42 POSIX.1‐2017, Section 12.2, Utility Syntax Guidelines.
43
44 The following options shall be supported by the implementation:
45
46 -h For each file operand that names a file of type symbolic
47 link, chgrp shall attempt to set the group ID of the symbolic
48 link instead of the file referenced by the symbolic link.
49
50 -H If the -R option is specified and a symbolic link referencing
51 a file of type directory is specified on the command line,
52 chgrp shall change the group of the directory referenced by
53 the symbolic link and all files in the file hierarchy below
54 it.
55
56 -L If the -R option is specified and a symbolic link referencing
57 a file of type directory is specified on the command line or
58 encountered during the traversal of a file hierarchy, chgrp
59 shall change the group of the directory referenced by the
60 symbolic link and all files in the file hierarchy below it.
61
62 -P If the -R option is specified and a symbolic link is speci‐
63 fied on the command line or encountered during the traversal
64 of a file hierarchy, chgrp shall change the group ID of the
65 symbolic link. The chgrp utility shall not follow the sym‐
66 bolic link to any other part of the file hierarchy.
67
68 -R Recursively change file group IDs. For each file operand that
69 names a directory, chgrp shall change the group of the direc‐
70 tory and all files in the file hierarchy below it. Unless a
71 -H, -L, or -P option is specified, it is unspecified which of
72 these options will be used as the default.
73
74 Specifying more than one of the mutually-exclusive options -H, -L, and
75 -P shall not be considered an error. The last option specified shall
76 determine the behavior of the utility.
77
79 The following operands shall be supported:
80
81 group A group name from the group database or a numeric group ID.
82 Either specifies a group ID to be given to each file named by
83 one of the file operands. If a numeric group operand exists
84 in the group database as a group name, the group ID number
85 associated with that group name is used as the group ID.
86
87 file A pathname of a file whose group ID is to be modified.
88
90 Not used.
91
93 None.
94
96 The following environment variables shall affect the execution of
97 chgrp:
98
99 LANG Provide a default value for the internationalization vari‐
100 ables that are unset or null. (See the Base Definitions vol‐
101 ume of POSIX.1‐2017, Section 8.2, Internationalization Vari‐
102 ables for the precedence of internationalization variables
103 used to determine the values of locale categories.)
104
105 LC_ALL If set to a non-empty string value, override the values of
106 all the other internationalization variables.
107
108 LC_CTYPE Determine the locale for the interpretation of sequences of
109 bytes of text data as characters (for example, single-byte as
110 opposed to multi-byte characters in arguments).
111
112 LC_MESSAGES
113 Determine the locale that should be used to affect the format
114 and contents of diagnostic messages written to standard
115 error.
116
117 NLSPATH Determine the location of message catalogs for the processing
118 of LC_MESSAGES.
119
121 Default.
122
124 Not used.
125
127 The standard error shall be used only for diagnostic messages.
128
130 None.
131
133 None.
134
136 The following exit values shall be returned:
137
138 0 The utility executed successfully and all requested changes were
139 made.
140
141 >0 An error occurred.
142
144 Default.
145
146 The following sections are informative.
147
149 Only the owner of a file or the user with appropriate privileges may
150 change the owner or group of a file.
151
152 Some implementations restrict the use of chgrp to a user with appropri‐
153 ate privileges when the group specified is not the effective group ID
154 or one of the supplementary group IDs of the calling process.
155
157 None.
158
160 The System V and BSD versions use different exit status codes. Some
161 implementations used the exit status as a count of the number of errors
162 that occurred; this practice is unworkable since it can overflow the
163 range of valid exit status values. The standard developers chose to
164 mask these by specifying only 0 and >0 as exit values.
165
166 The functionality of chgrp is described substantially through refer‐
167 ences to chown(). In this way, there is no duplication of effort
168 required for describing the interactions of permissions, multiple
169 groups, and so on.
170
172 None.
173
175 chmod, chown
176
177 The Base Definitions volume of POSIX.1‐2017, Chapter 8, Environment
178 Variables, Section 12.2, Utility Syntax Guidelines
179
180 The System Interfaces volume of POSIX.1‐2017, chown()
181
183 Portions of this text are reprinted and reproduced in electronic form
184 from IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
185 table Operating System Interface (POSIX), The Open Group Base Specifi‐
186 cations Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of
187 Electrical and Electronics Engineers, Inc and The Open Group. In the
188 event of any discrepancy between this version and the original IEEE and
189 The Open Group Standard, the original IEEE and The Open Group Standard
190 is the referee document. The original Standard can be obtained online
191 at http://www.opengroup.org/unix/online.html .
192
193 Any typographical or formatting errors that appear in this page are
194 most likely to have been introduced during the conversion of the source
195 files to man page format. To report such errors, see https://www.ker‐
196 nel.org/doc/man-pages/reporting_bugs.html .
197
198
199
200IEEE/The Open Group 2017 CHGRP(1P)