Change file ownership with chown
Assign a file or whole directory tree to a different user and group, common after root-created copies or when fixing web server permissions.
01Command
$ sudo chown user:group file-or-dir02What it does
The syntax is chown owner[:group] target; chown alice file changes only the owner, while chown alice: file also sets the group to alice's login group. -R recurses through a directory tree (chown -R www-data:www-data /var/www/html). Verify with ls -l or stat -c '%U:%G %n'. For group-only changes, chgrp or chown :group file avoids touching the owner. Reference a group by ID with a leading colon-plus-number (:1000), and note ownership changes are recorded by auditd/SELinux contexts may need relabeling on SELinux systems.
03Risk
04Undo
$ sudo chown previous-owner:previous-group file-or-dir05Sources
- chown(1) — change file owner and groupEvidence: The chown man page documents setting owner and group via 'owner[:group]' syntax and the -R option to operate recursively.
Last verified: 2026-09-17 · Category: Files & Folders
06Related solutions
Add or remove read, write, and execute permission for the owner, group, or others using symbolic or octal modes.
Find every occurrence of a pattern across all files in a tree, printed as file:line:number matches.
Unpack a gzipped tarball into the current directory while printing each file as it is extracted.