Change group ownership (update the group ID of files.)

      chgrp [-fhv] [-R [-H | -L | -P]] group file ...

The group operand can be either a group name, or a numeric group ID.


   -R     Recurse: Change the mode of file hierarchies rooted in the files
          instead of just the files themselves.

   -R -H  Follow symbolic links on the command line
          (by default Symbolic links within the tree are not followed.)    

   -R -L  All symbolic links are followed.

   -R -P  No symbolic links are followed. (default)

   -f     Force, ignores errors, except for usage errors and doesn't query
          about strange modes (unless the user lacks permissions).

   -h     If the file is a symbolic link, the group ID of the link itself
          is changed rather than the file that is pointed to.

   -v     Verbose, show filenames as the group is modified.

The user invoking chgrp must belong to the specified group and be the owner of the file, or be the super-user.

The chgrp utility exits 0 on success, and >0 if an error occurs.

In previous versions of this system, symbolic links did not have groups.
The -v option is non-standard and its use in scripts is not recommended.


Change the group ownership of a file to 'OpsGroup':

$ chgrp OpsGroup /usr/database/demo.dbf

Change the group ownership of a directory and all sub-directories to 'OpsGroup', verbosely display all the filenames affected:

$ chgrp -v -R OpsGroup /usr/database/

“If an organization carries the word 'united' in its name, it means it isn’t, e. g., United Nations, United Arab Republic, United Kingdom, United States” - Professor Charles I. Issawi

Related macOS commands

chflags - Change a file or folder's flags.
chmod - Change access permissions.
chown - Change file owner and group.
install - Copy files and set attributes.
umask - Users file creation mask.

Copyright © 1999-2024
Some rights reserved