Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Possible Duplicate:
Can’t rename a directory that I own

I am trying to understand why when a dir X is owned by user A cannot rename it when parent dir of X is owned by user B. Can anyone please explain?

$ls -l ~
drwxr-xr-x 11 root root   4096 Jan 31 09:43 mymedia

~/mymedia$ ls -l
drwxr-xr-x  6 rag rag  4096 Jan 31 08:34 Entertainment

~/mymedia$ mv  Entertainment/ entertainment
mv: cannot move `Entertainment/' to `entertainment': Permission denied
share|improve this question

marked as duplicate by Gilles, rahmu, ire_and_curses, Thor, uther Feb 1 '13 at 0:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Why does root own something in your home folder? –  Kevin Jan 31 '13 at 20:39
    
i happened to copy some stuff from my windows partition to linux partition. it by default is owned by root. –  rag Jan 31 '13 at 20:40

1 Answer 1

up vote 4 down vote accepted

When you rename a file, you don't change the file, you change its parent directory. A file name is an entry in a directory. Think of phone directories, to change the name associated with a phone number in a directory, you need to modify the directory, not the phone line. The name is associated with the phone line only in that directory. That phone number may be in another directory under a different name (hard links).

There's a caveat though for renaming directories as directories contain a reference to their parent (their .. entry). To be able to move a directory, it's not enough to have write permission to the old parent (to remove the entry) and the new parent (to add a new entry), you also need to have write permission to the directory itself to update the .. entry (if the old and new parent are different).

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.