chgrp changes the user group for a file or a directory. You can only use it if you are the file/directory owner or the POSIX administrator.
Only the POSIX administrator can change the user group for each file as required.
Another user may only change the group for his own files, provided that the user is entered in the /etc/group file as a member of the new group.
If chgrp is called by a user without POSIX administrator permissions, then all set s-bits are reset for the specified files (see chmod).
Syntax
chgrp[ -h][ -R] gid file |
If file is a symbolic link, chgrp changes the group ID of the symbolic link itself. Without this option, the group ID of the file referenced by the symbolic link is changed.
(recursive)
(group id)
Name of the file or directory for which the user group is to be redefined. You can also list any number of files and/or directories. |
Error
file
|
File
/etc/group The group file /etc/group contains a list of all existing user groups. Each line of this file consists of four colon-separated fields:
Only the POSIX administrator is permitted to create new user groups and to enter new group members. |
Locale
The following environment variables affect the execution of chgrp: LANG Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined. LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_CTYPE Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments). LC_CTYPE governs character classes, character conversion (shifting) and the behavior of character classes in regular expressions. LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES. |
Example
You are currently working under the login name cindy; this name is entered in the /etc/group file as a member of the user groups ag and prog. At present, you belong to the user group ag as is evident from the fact that the name ag is entered for "group" when you create new files:
You now wish to change the user group for file; the new group is to be prog. To do this, you change the group for file with chgrp:
|
See also
chmod, chown, id, newgrp chown() [4] |