LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How exactly does Linux file permission inheritance work (https://www.linuxquestions.org/questions/linux-newbie-8/how-exactly-does-linux-file-permission-inheritance-work-434838/)

HGeneAnthony 04-13-2006 11:47 AM

How exactly does Linux file permission inheritance work
 
I'm familar with file permissions under Linux. However, one thing I'm not sure of is how come I'm able to delete a file when I shouldn't have the right to. I have it set that the parent folder has rights to read/write/execute but the file only has read/execute permission. So why am I able to delete the file? I'm using Debian Sarge and here's the parent folder's permission:

drwxrwxr-x 2 root users 48 2006-04-13 11:35 test

The file's permissions are as so:

-rw-r--r-- 1 root root 0 2006-04-13 12:45 testfile

Now as geneanthony which belongs to the user's group I can delete testfile. However, the permissions on the file says I can't, how come I can? What's the purpose of a file ACL if the parent folder always overrides it?

Dudydoo 04-13-2006 12:22 PM

Because if a folder/directory has write permission then it overrules the file permissions. Usually you would give the directory read and execute permissions enabling someone to enter the directory, then they can only do what they have permission to do to the file.

I'd suggest you read up a bit more on permissions and create a couple of accounts to play around with to test things out.

Also investigate the 'sticky bit' permissions.

HGeneAnthony 04-13-2006 01:09 PM

Reply
 
I am playing around with a few accounts including one circumstance where I changed the permission to give write permission on the file, but none on the folder and I couldn't delete it anymore, so if the folder doesn't have write permission I can't write to a folder no matter what. So basically the only bit that seems to work on files is the executable bit correct? I mean if I don't have read/execute permission on the folder I can't go into the directory anyway and I'll have read permission since it would be inherited as well. I'm not opposed to this system, I'm just trying to understand it.

merchtemeagle 04-13-2006 01:42 PM

Quote:

I am playing around with a few accounts including one circumstance where I changed the permission to give write permission on the file, but none on the folder and I couldn't delete it anymore, so if the folder doesn't have write permission I can't write to a folder no matter what.
You can write to the file. Open it in $EDITOR, make changes and save it. That should be no problem. You can't change the contents of the directory though, because you have no writing permission there.

HGeneAnthony 04-13-2006 05:14 PM

Reply
 
I see what you mean. OK, this makes sense now. Thank you for your help.

Dudydoo 04-14-2006 10:20 AM

File permissions:

r = read the contents of the file
w = modify the file
x = run the file as an executable

Directory permissions:

r = list the contents of the directory, but not 'ls' into it
w = delete or add a file in the directory
x = move into the directory


All times are GMT -5. The time now is 06:35 AM.