chgrp Command: Tutorial & Examples
Change the group ownership of a file or directory
The chgrp
command is a Linux command that allows you to change the group ownership of a file or directory. It stands for "change group."
To use the chgrp
command, you need to specify the name of the group that you want to assign to the file or directory, and then the name of the file or directory that you want to
change. For example:
chgrp groupname /path/to/file
This command will change the group ownership of the file /path/to/file
to groupname
.
You can also use the -R
option to recursively change the group ownership of all files and directories within a directory. For example:
chgrp -R groupname /path/to/directory
This command will change the group ownership of the directory /path/to/directory
and all of its contents (including subdirectories and files) to groupname
.
Note that you must be the owner of the file or directory, or have superuser privileges (using the sudo
command), to use the chgrp
command.