Set the owner and group of one file.
sudo chown alice:developers ./report.txtChange file ownership. Use elevated privileges only when needed.
chown [OPTION]... [OWNER][:[GROUP]] FILE...Set the owner and group of one file.
sudo chown alice:developers ./report.txtChange ownership of a directory tree (review the path carefully).
sudo chown -R alice:developers ./project| Option / clause | Description |
|---|---|
OWNER | Set the file owner; a user name or numeric ID may be used. |
OWNER:GROUP | Set owner and group together. |
-R, --recursive | Change ownership recursively. |
-h, --no-dereference | Affect symbolic links rather than their targets (where supported). |
-c, --changes | Report only files whose ownership changed. |
-v, --verbose | Report every processed file. |
--reference=RFILE | Copy owner and group from RFILE. |
Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.