2025-03-14 21:59:59 -06:00
|
|
|
# chown
|
|
|
|
|
|
|
|
|
|
> Change user and group ownership of files and directories.
|
|
|
|
|
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/chown-invocation.html>.
|
|
|
|
|
|
|
|
|
|
- Change the owner user of a file/directory:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`sudo chown {{user}} {{path/to/file_or_directory}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Change the owner user and group of a file/directory:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`sudo chown {{user}}:{{group}} {{path/to/file_or_directory}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Change the owner user and group to both have the name `user`:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`sudo chown {{user}}: {{path/to/file_or_directory}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Recursively change the owner of a directory and its contents:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`sudo chown {{[-R|--recursive]}} {{user}} {{path/to/directory}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Change the owner of a symbolic link:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`sudo chown {{[-h|--no-dereference]}} {{user}} {{path/to/symlink}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Change the owner of a file/directory to match a reference file:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`sudo chown --reference {{path/to/reference_file}} {{path/to/file_or_directory}}`
|