chgrp command

(change group permissions)

The chgrp command is used to change the group that has access to files and directories. All files in linux belong to an owner, and a group. The owner is set by the chown command, and the group by the chgrp command.

The format is chgrp newgroup filename(s) [-options]

>ls -l
-rwxrwx--- 1 rob rob 35 Jun 13 21:14 file.txt
>chgrp clients file.txt
>ls -l
-rwxrwx--- 1 rob clients 35 Jun 13 21:14 file.txt
>

Line 1 is the list command (ls), with long format
Line 2 is the output of ls, showing there is one file, called file.txt (owned by 'rob', group access for group 'rob')
Line 3 is the chgrp command, with the new group name being 'clients'
Line 4 is the ls command again, to show us if the chgrp command was successful
Line 5 shows that the file is owned by rob, but now group access is 'clients'

There are a few options you can add to chgrp, you can see them on the chgrp man page

Back to index