Chown
Linux Terminal Util
chown Command Reference
The chown
command is used to change the ownership of files or directories. You can specify the new owner, group, or both, and also use a reference file for the change. It is especially useful for adjusting ownership when managing file permissions and security.
Syntax
- NewOwner: Specifies the new owner and/or group. It can be:
- OWNER: Just the username or numeric user ID.
- OWNER.GROUP or OWNER:GROUP: Both the owner and the group are changed.
- OWNER. or OWNER:: Only the owner is changed, and the group is set to the owner's login group.
- .GROUP or :GROUP: Only the group is changed.
Options
-
-c
,--changes
: Verbosely describe the action for each file whose ownership changes. -
--dereference
: Operate on the files the symbolic links point to, not the links themselves. -
-f
,--silent
,--quiet
: Suppress error messages for files whose ownership cannot be changed. -
-h
,--no-dereference
: Act on symbolic links themselves (default behavior). -
--reference=FILE
: Use the user and group of a reference file instead of specifying NewOwner. -
-R
,--recursive
: Recursively change ownership of directories and their contents. -
-v
,--verbose
: Verbosely describe the action or non-action taken for each file.
Examples
-
Change the owner of a file:
-
Recursively change ownership of everything in a directory:
-
Change ownership of only hidden files in a directory: To avoid issues with symbolic links, use this command: