Previous Section  < Day Day Up >  Next Section

Recipe 9.5. Setting File Ownership with chown

9.5.1 Problem

You need to change ownership on a file or directory. Perhaps you've copied something to someone else's directory but she still can't edit it, because it's owned by you. Many Linux problems result from incorrect ownership or permission. You're seeing messages like "Permission denied" or "File is read-only" when it shouldn't be.

9.5.2 Solution

Use chown (change owner) to change the file owner, the file and group owner, or the group owner:

# chown user filename

# chown user:group filename

# chown :group filename

For example:

$ chown -v carlas:share index.txt

changed ownership of `index.txt' to carlas:share

$ chown -v :share toc.txt

changed ownership of `toc.txt' to :share

9.5.3 Discussion

Ordinary users can only make changes to files that they own, and they cannot transfer file ownership to another user. However, ordinary users can change group file ownership, provided that they belong to both the original group and the final group.

9.5.4 See Also

  • info chown

    Previous Section  < Day Day Up >  Next Section