File ownership

The command chown allows the user to change the ownership of a file they own to another user (and group). To use chown, a user must have the privileges of the target user. In most cases, only root can transfer ownership of a file to another user.

The reason for this restriction as it would cause security problems if allowed to unprivileged users. Here is an example: If a system has disk quotas enabled, Alice could create a world-writable file under a directory accessible only by her (so no one else could access that world-writable file in the directory), and then run chown to make that file owned by another user Bill. The file would then count under Bill's disk quota even though only Alice can use the file.

However, chown is an important operation for the root user. For example:

chown alice file1

Changes the owner of file1 to alice, but the group is left unchanged.

chown alice:students file2

Changes the owner of file2 to alice, and the group to students.

chown -R alice:students /home/alice

Changes recursively the owner of all files in the directory /home/alice to alice, and the group to students.