"cannot unlink" error? (can't delete file)


#1

I’m trying to delete a directory containing a directory and file that’s write-protected or some-such. I tried changing permissions for all directories and files, but it gives this error:

rm -r temp
rm: directory temp/data/logs' is write protected; descend into it anyway? y rm: remove write-protected filetemp/data/logs/views…log’? y
rm: cannot unlink temp/data/logs/views..log': Permission denied rm: cannot remove directorytemp/data/logs’: Directory not empty
rm: cannot remove directory temp/data': Directory not empty rm: cannot remove directorytemp’: Directory not empty

Any hints? This was originally part of a PHP script that I ended up removing since I didn’t like it…


#2

Are there any files you don’t own inside the directory tree (find temp ! -user yourusername)? If so, are you able to remove those files by hand?

Does using rm -rf temp/ help?


#3

Checking ownership with that command lists:
temp/data/logs
temp/data/logs/views…log

(and can’t delete the files by hand) “rm -rf temp/” gives the same errors as before… Hrm.

Clarification: This is on a subdomain I made for a friend; I was trying out a few PHP scripts for creating automated image galleries and such since I don’t expect her to be able to make a full website on her own - so I logged in as her username. After trying to delete one of the PHP scripts, this directory was left behind…


#4

I did some digging and found a comment that it has to do with the user not having “super-user” status. But I don’t know why this would require super-user status to delete… And don’t know how a super-user can go delete it (my original domain user?). Stupid PHP thing. grrrr~ :stuck_out_tongue:


#5

It’s probably because of files created by PHP. You can write a PHP script to remove the files - that’s probably the quickest way to fix this. Otherwise just write support and have them do it for you.

You can remove files you don’t own in a directory you do own - however it gets a bit dicier when PHP creates new directories.