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
| Name | Type | Description |
|---|---|---|
| GROUP | operand | group name or numeric ID |
| FILE | operand | fixture path |
| -h | option | operate 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"