Owner and group: chown, chgrp

Updated November 1, 2026

A file has an owner and a group. chown changes the owner, chgrp the group. Only root may change the owner.

sudo chown alice file            # owner alice
sudo chgrp devs file             # group devs
sudo chown alice:devs file       # owner and group at once
sudo chown -R alice:devs dir/    # recursively

Sample output

$ ls -l report.txt
-rw-r--r-- 1 student student 0 Jul 26 03:48 report.txt
$ chown root report.txt
chown: changing ownership of 'report.txt': Operation not permitted
$ sudo chown root:adm report.txt
$ ls -l report.txt
-rw-r--r-- 1 root adm 0 Jul 26 03:48 report.txt

The alice:devs form sets owner and group in one command. The rwx permissions then decide what the owner and group may actually do with the file.

Common mistakes

You cannot give your own file away. chown root report.txt as a normal user answers chown: changing ownership of 'report.txt': Operation not permitted, even though the file is yours. Only root hands ownership over: otherwise anyone could dump their files on a neighbour and charge them to that neighbour's disk quota. chgrp is different. It works without root when you own the file and belong to that group: chgrp devs f1 changes the group with no sudo.

The colon is read in two halves, and three forms give three results. chown alice:devs f sets owner and group. chown :devs f touches the group only, so it does the job of chgrp. And chown root: f, with the part after the colon left empty, sets root as the owner and also moves the group to root's login group: the file ends up root root even if the group was adm. The old dot form still works but complains: chown: warning: '.' should be ':'.

chown -R does not follow symbolic links. If a directory holds a link link -> /etc/hostname, then after sudo chown -R student:student d the link itself changes owner (lrwxrwxrwx 1 student student ... link -> /etc/hostname) while /etc/hostname stays root root. That is usually what you want, but if you expected the ownership to reach the files behind the links, nothing happens and nothing is printed.

Used in

You need this in the lesson Users and permissions.