commands
chown — change owner and group
Changes ownership when permitted. A different owner normally requires privilege on Linux. Changing ownership can clear special bits; verify state afterward. GNU -h operates on a symlink itself where supported. No recursive changes in this lab. Example assumes a fresh permissions lab fixture.
Formal Syntax & Structure
linux syntaxlinux
chown [OPTION] OWNER[:GROUP] FILE...Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| OWNER | operand | owner name or numeric ID |
| GROUP | operand | optional group |
| FILE | operand | fixture path |
| -h | option | operate on symlink itself |
Return Value
exit status and output
Changes ownership when permitted. A different owner normally requires privilege on Linux. Changing ownership can clear special bits; verify state afterward. GNU -h operates on a symlink itself where supported. No recursive changes in this lab.
Working Example
Example Snippetlinux
chown "$(id -u)" report.txttest "$(stat -c %u report.txt)" = "$(id -u)" && printf "owner retained\n"