I create a file under my user esolve
and then su root
and use chown to change its user to root
then I returned to user esolve
I notice I can still delete the file with rm
why?

- 1,333
2 Answers
Whether you can create, rename and delete a file does not depend on the ownership and access rights of the file but of those of the parent directory.
If you have write access to the directory (in the normal case, it's more complicated with richacl) then you can do this. The exception are directories with the sticky bit (the "SUID"/"SGID" bit for "others", see man chmod
) set like /tmp
usually. In such directories only the directory owner or the file owner can do this, other users with write access cannot.

- 90,279
Because you can remove the file, so if you can read that file, virtually you have "modified permission"
Say you have file named foo
owned by root
and its readable by you
(everyone), under a dir what owned by you
-rw-r--r-- 1 root root 4 May 11 12:34 foo
drwxr-xr-x 2 you root 4.0K May 11 12:34 ./
Copy that file to a new file:
$ cp foo bar
-rw-r--r-- 1 root root 4 May 11 12:34 foo
-rw-r--r-- 1 you you 4 May 11 12:36 bar
drwxr-xr-x 2 you root 4.0K May 11 12:36 ./
Edit the file "bar" to whatever you like
Move "bar" to "foo"
$ mv bar foo
-rw-r--r-- 1 you you 4 May 11 12:36 foo
Now you have new file with same name, but of course different owner. But the point here is the content is changed
You doesnt have the modified permission, but you can rename/move/rm. I really dont get this kind of design!!

- 948
- 1
- 10
- 12