Set group

2 snippets in Bash & Linux

SHBash & Linux

Change File Owner

SH · Permissions & Ownership
Syntax
chown [options] user[:group] file...
Example
sudo chown www-data:www-data /var/www/html -R
sudo chown deploy app/
sudo chown :staff shared/

Note Requires root/sudo for files you do not own. user:group changes both at once. :group (with colon, no user) changes only the group. -R applies recursively. Be careful with -R on directories containing symlinks; use --no-dereference to avoid following them.

Change Group Ownership

SH · Permissions & Ownership
Syntax
chgrp [options] group file...
Example
sudo chgrp developers /opt/shared-repo -R

Note Equivalent to chown :group. -R applies recursively. You can only change to a group you belong to unless you are root.

Frequently asked questions

How does Bash & Linux handle set group?
Bash & Linux covers this with 2 copy-ready snippets on this page. The "Change File Owner" snippet in Bash & Linux uses `chown [options] user[:group] file...`.
Which command does the Bash & Linux example use?
The "Change File Owner" snippet uses `chown [options] user[:group] file...`, from the Permissions & Ownership section of the Bash & Linux cheat sheet.
What other Bash & Linux snippets are shown for "set group"?
Besides "Change File Owner", this page also shows "Change Group Ownership".
Is there anything to watch out for?
Yes. For "Change File Owner": Requires root/sudo for files you do not own. user:group changes both at once. :group (with colon, no user) changes only the group. -R applies recursively. Be careful with -R on directories containing symlinks; use --no-dereference to avoid following them.