Permissions, users and access

Command chgrp

Change file group

Linux · Bash examples · commands run on the selected server

When to use chgrp

Use chgrp to change a file's group without changing its owner. Shared-project access depends on both group ownership and mode bits, so inspect both before assuming a group member can write.

Syntax

chgrp [OPTIONS] GROUP FILE…

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

-R
Change group recursively.
-v
Show processed objects.
--reference=FILE
Use the group of the specified file in GNU chgrp.

Usage examples

Assign a group to a file

chgrp developers ./report.txt

The report is assigned to the named group if the account is permitted to make that change.

Change directory group

chgrp developers ./project

The directory's group changes, but existing children do not change without a separate recursive operation.

Copy sample group

chgrp --reference=./reference.txt ./report.txt

The target takes the reference file's group, avoiding a manually typed group name.

Notes and limitations

  • Typically, the owner can only assign groups to which he belongs; other changes require additional permissions.
  • Before recursively changing the group, check the path and link handling policy.

Common questions and troubleshooting

Why is a group change denied?

An ordinary owner generally can select only groups they belong to. Check ownership and membership rather than assuming any group is permitted.

Will changing a directory group update all files inside?

No. This invocation changes the directory itself. Existing children and the policy for newly created files must be considered separately.

Further help

Options vary by version and distribution. Check the installed documentation with this command: man chgrp.