Recipe 9.5. Setting File Ownership with chown

 < Day Day Up > 

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

     < Day Day Up > 


    Linux Cookbook
    Linux Cookbook
    ISBN: 0596006403
    EAN: 2147483647
    Year: 2004
    Pages: 434

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net