2013-12-25 12:59:24 +00:00
|
|
|
# chown
|
|
|
|
|
2019-02-11 18:00:49 +00:00
|
|
|
> Change user and group ownership of files and directories.
|
2021-04-01 16:54:26 +01:00
|
|
|
> More information: <https://www.gnu.org/software/coreutils/chown>.
|
2013-12-25 12:59:24 +00:00
|
|
|
|
2019-02-08 00:31:19 +00:00
|
|
|
- Change the owner user of a file/directory:
|
2013-12-25 12:59:24 +00:00
|
|
|
|
2019-02-08 00:31:19 +00:00
|
|
|
`chown {{user}} {{path/to/file_or_directory}}`
|
2013-12-25 12:59:24 +00:00
|
|
|
|
2019-02-08 00:31:19 +00:00
|
|
|
- Change the owner user and group of a file/directory:
|
2015-10-22 08:31:52 +01:00
|
|
|
|
2019-02-08 00:31:19 +00:00
|
|
|
`chown {{user}}:{{group}} {{path/to/file_or_directory}}`
|
2013-12-25 12:59:24 +00:00
|
|
|
|
2024-02-27 14:12:54 +00:00
|
|
|
- Change the owner user and group to both have the name `user`:
|
|
|
|
|
|
|
|
`chown {{user}}: {{path/to/file_or_directory}}`
|
|
|
|
|
2019-02-11 18:00:49 +00:00
|
|
|
- Recursively change the owner of a directory and its contents:
|
2013-12-25 12:59:24 +00:00
|
|
|
|
2019-02-11 18:00:49 +00:00
|
|
|
`chown -R {{user}} {{path/to/directory}}`
|
2013-12-25 12:59:24 +00:00
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
- Change the owner of a symbolic link:
|
2015-10-22 08:31:52 +01:00
|
|
|
|
2013-12-25 12:59:24 +00:00
|
|
|
`chown -h {{user}} {{path/to/symlink}}`
|
2014-08-18 11:45:43 +01:00
|
|
|
|
2019-02-08 00:31:19 +00:00
|
|
|
- Change the owner of a file/directory to match a reference file:
|
2014-08-18 11:45:43 +01:00
|
|
|
|
2019-02-08 00:31:19 +00:00
|
|
|
`chown --reference={{path/to/reference_file}} {{path/to/file_or_directory}}`
|