commands

chgrp — change owning group

Changes group where authorized; an ordinary file owner can normally select a group they belong to. -h selects a symbolic link itself where supported. Zero on success, nonzero on failure. Example assumes a fresh permissions lab fixture.

Formal Syntax & Structure

linux syntaxlinux
chgrp [OPTION] GROUP FILE...

Parameters & Attributes

NameTypeDescription
GROUPoperandgroup name or numeric ID
FILEoperandfixture path
-hoptionoperate on symlink itself

Return Value

exit status and output

Changes group where authorized; an ordinary file owner can normally select a group they belong to. -h selects a symbolic link itself where supported. Zero on success, nonzero on failure.

Working Example

Example Snippetlinux
chgrp "$(id -g)" report.txttest "$(stat -c %g report.txt)" = "$(id -g)" && printf "group retained\n"
Linux Reference