How to change the group of a file in Linux?

Published on Aug. 22, 2023, 12:18 p.m.

To change the group ownership of a file in Linux, you can use the chgrp command followed by the name of the group and the file you want to modify. Here is the basic syntax:

sudo chgrp group_name file_name

For example, to change the group ownership of a file called “example.txt” to the group “admin”, you could use the following command:

sudo chgrp admin example.txt

Note that you need to have root privileges (or be a member of the sudo group) to use the chgrp command.

Tags: