Permissions

Linux chown command

Change file ownership. Use elevated privileges only when needed.

Availability: Common Linux commands; shell built-ins and external implementations may differ by distribution.中文

Syntax

chown [OPTION]... [OWNER][:[GROUP]] FILE...

Examples

Set the owner and group of one file.

sudo chown alice:developers ./report.txt

Change ownership of a directory tree (review the path carefully).

sudo chown -R alice:developers ./project

Parameters, options and clauses

Option / clauseDescription
OWNERSet the file owner; a user name or numeric ID may be used.
OWNER:GROUPSet owner and group together.
-R, --recursiveChange ownership recursively.
-h, --no-dereferenceAffect symbolic links rather than their targets (where supported).
-c, --changesReport only files whose ownership changed.
-v, --verboseReport every processed file.
--reference=RFILECopy owner and group from RFILE.
Safety note

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.

Official reference ↗Back to directory