In this section, we will see how the rights on Linux work and sometimes it may be a little bit tricky.
If you want to delete a file, you don't even need rights on it. The only thing you need is to have the “write” right on its parent. For example : take this “tree”
The owner of the folders and the file c.txt is root:root The rights are :
- a : all the rights for the owner; execution right for the group and everyone (x to go through the folder) - b : all the rights for the owner; execution and write rights for the group and everyone - c.txt : all the rights for the owner; none for the group and everyone
So now connect with another user, in this example “user” and try this command : rm a/b/c.txt The system will ask you if you want to delete this write-protected file, and if you answer yes, the file will be deleted.
But now if you try to remove the “write” right on b, it won't work anymore, even if you have all the rights on the file c.txt.