Rm: cannot be deleted: permission denied

max@serv$ whoami max max@serv$ ls -la ./defines.php -rwxrwxrwx 1 max max 1985 2011-11-16 02:01 ./defines.php max@serv$ chmod 0777 ./defines.php max@serv$ rm ./defines.php rm: cannot remove `./defines.php': Permission denied max@serv$ 

How to delete this file?

+45
linux bash
Nov 17 '11 at 23:10
source share
1 answer

The code says it all:

 max@serv$ chmod 777 . 

Well, he does not say everything.

On UNIX and Linux, the ability to delete a file is not determined by the access bits of this file. It is determined by the access bits of the directory that contains the file.

Think of it this way: deleting a file does not modify this file. You are not writing a file, so why the "w" in the file? To delete a file, you need to change the directory pointing to the file, so you need a "w" in that directory.

+122
Nov 17 '11 at 23:14
source share