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.

I have a file that has 10 parent directories. When I change the file's owner with chown command new owner still can't write to file because the file's parent directories still have a different owner. Is there a way to also change parent directories' owner?

If not, what's the best way to temporarily grant a user permission to change a file inside nested directories?

share|improve this question
    
What you said is incorrect, the user does not need ownership of the containing directory to be able to edit the file. Directory ownership is only required if the user needs to create or delete files. Are you sure the user has the ability to even read the directory? It needs the execute bit to do anything with files inside the directory. –  Patrick Mar 7 '12 at 18:54
    
@Patrick No, User doesn't have permission to read the directory. –  hknik Mar 7 '12 at 19:01

2 Answers 2

up vote 3 down vote accepted

The user only needs the execute bit present on a directory containing a file to be able to access the file. If the execute bit is set on the directory and the user has write permissions to the file he can edit that file. Without write perms on the directory he wont be able to create or delete files (even if he owns the file), but he will be able to edit them. Note though that without read permissions (only execute is set) the user wont be able to get a directory listing, he'll have to know the exact file name of the file to be able to access it.

So if our file is at dirname/filename.txt and user owns the file:

rwx--x--x dirname
User can edit dirname/filename.txt
User cannot create dirname/filename2.txt
User cannot delete dirname/filename.txt
User cannot ls dirname

rwxr-xr-x dirname
User can edit dirname/filename.txt
User cannot create dirname/filename2.txt
User cannot delete dirname/filename.txt
User can ls dirname

rwxrwxrwx dirname
User can do anything

NOTE
These rules do not apply if the directory has the sticky bit applied. The stick bit changes the behavior completely (the /tmp directory has the sticky bit applied).

share|improve this answer

To answer your question I could recommend the usage of ACLs Access Control Lists

Hope it helps!

share|improve this answer

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.