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.

Recently I tried to move a directory that I own to another directory (which I also own), but I couldn't. I then noticed that I don't own the parent directory.

This made me wonder what are the rules for moving a directory in UNIX. Do you need to have read/write permissions to both it and its parent? Also what happens if it contains files or directories that you don't own?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Your user needs write/executable (wx) permissions on directory to make create/delete any files in it (even if you don't own them and don't have read permissions). There is no need in owning it.

Thus to move directory you need to have wx premissions on parent directory to be able to operate with files and dirs in it and wx on directory you're going to move and on all nested directory (permissions on files in it don't matter at all, if you're not going to change them).

share|improve this answer
1  
Small mistake: you do not need the read permissions for a directory, only x ("descend") and w ("write"). Test it with chmod 300 test && mv test/{a,A} –  Lekensteyn Jul 6 '12 at 10:06
1  
Yes, you're right. Fixed it. Thanks. –  rush Jul 6 '12 at 10:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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