Why can I delete a 755 file when I'm not the owner? [duplicate]
I have this file:
$ ls -l store.sh
-rwxr-xr-x 1 root apache 117 Feb 5 2016 store.sh
$ id
uid=48(apache) gid=48(apache) groups=48(apache)
I think that I haven't the permission to edit this file but was possible delete and replace the file. How can it be? Can someone explain this behaviour?
Solution 1:
You don't need write permissions on a file to delete or move (rename) it. You need write permissions on the directory containing the file, because deleting or renaming are not operations on the file, but operations on the directory's list of files. So in this case the directory of this file probably has write access for the apache
user or the apache
group.