permissions

chown

Changes the owner and/or group of files and directories. Requires appropriate privileges (usually root) to reassign ownership.

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

Common flags

Flag Purpose
-R Recurse into directories
-h Affect symlinks themselves, not their targets
-v Print each change
-c Print only files that actually change
--reference Copy owner/group from a reference file

Examples

chown alice file.txt

Change owner to alice

chown alice:devs project/

Set owner and group on a directory

chown -R www-data:www-data /var/www/site

Recursively assign a web root to the web-server user

chown --reference=template.conf new.conf

Copy owner and group from another file

Gotcha

Following a symlink is the default -- pass -h to change the link itself instead of its target, especially in -R runs.

Related commands

← All Linux commands · Linux cheat sheet