firoz@rhel:~$
all notes
Linux BasicsCompletedJune 2026

Linux Command: chown

A compact learning note covering chown syntax, ownership patterns, recursive mode, output examples, and the most useful chown options for Linux file permission management.

linuxshellpermissionsownership

Purpose

Use chown to change file and directory ownership safely while confirming results, especially when preparing shared resources or fixing permission issues.

Key points

  • ›chown changes the owner and optionally the group of files and directories.
  • ›Use user:group, user:, or :group syntax to set owner, group, or both.
  • ›-R applies ownership changes recursively to directories and nested files.
  • ›-v, -c, --from, and --reference are useful for safe, auditable updates.
  • ›Use -h or --no-dereference when you need to change symlink ownership itself instead of its target.

Notes

Note 1

Basic chown syntax

Change the owner of a single file. When only the owner is supplied, the existing group stays the same.

$ sudo chown alice notes.txt
$ ls -l notes.txt
Example basic chown output
$ sudo chown alice notes.txt
$ ls -l notes.txt
-rw-r--r-- 1 alice staff 0 Jun 24 14:00 notes.txt

Note 2

Change only the group or both owner and group

Use user:group to set both owner and group. Use :group when only the group should change. This is common when files move between user teams or project groups.

$ sudo chown alice:developers project.log
$ sudo chown :developers project.log
$ ls -l project.log
Owner and group change output
$ sudo chown alice:developers project.log
$ ls -l project.log
-rw-r--r-- 1 alice developers 4096 Jun 24 14:01 project.log

Note 3

Recursive ownership changes

Use -R to apply ownership changes to a directory and everything inside it. Add -v for feedback on each changed item.

$ sudo chown -R -v alice:developers /var/www/site
$ find /var/www/site -maxdepth 2 -printf '%M %u %g %f '
Recursive chown output
$ sudo chown -R -v alice:developers /var/www/site
changed ownership of '/var/www/site' from root:root to alice:developers
changed ownership of '/var/www/site/index.html' from root:root to alice:developers
$ find /var/www/site -maxdepth 2 -printf '%M %u %g %f\n'
-rwxr-xr-x alice developers site
-rw-r--r-- alice developers index.html

Note 4

Helpful chown options

-v shows each file changed, -c reports only when an ownership update actually happens, --from changes ownership only if the file currently has a specific owner:group, and --reference copies ownership from another file.

$ sudo chown -v alice:developers notes.txt
$ sudo chown -c alice:developers notes.txt
$ sudo chown --from=bob:staff alice:developers notes.txt
$ sudo chown --reference=template.txt notes.txt
$ sudo chown -h bob linkfile
Option output examples
$ sudo chown -v alice:developers notes.txt
changed ownership of 'notes.txt' from bob:staff to alice:developers
$ sudo chown -c alice:developers notes.txt
changed ownership of 'notes.txt' from bob:staff to alice:developers
$ sudo chown --from=bob:staff alice:developers notes.txt
changed ownership of 'notes.txt' from bob:staff to alice:developers
$ sudo chown --reference=template.txt notes.txt
changed ownership of 'notes.txt' from bob:staff to alice:developers

Note 5

Symlink ownership and verification

Use -h or --no-dereference to change the ownership of a symlink itself. Verify ownership with ls -l or stat after changes.

$ sudo chown -h bob linkfile
$ stat -c '%U %G %n' notes.txt
$ ls -l linkfile
Verify ownership output
$ sudo chown -h bob linkfile
$ stat -c '%U %G %n' notes.txt
alice developers notes.txt
$ ls -l linkfile
lrwxrwxrwx 1 bob developers 11 Jun 24 14:02 linkfile -> notes.txt