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.