550 Permission Denied Deleting Solved

550 Permission Denied
I used to have this problem rather frequently. The problem is basically for god knows what reason (ain’t got the technical details here), the files becomes undeletable whether using a FTP client and whatnots. This always pisses me off as I hate leaving cluttered stuff around my web space. Basically what I’ll do is rename the folder/file to something such as “deleteme” and then try praying that it will get deleted one day. However, the case is that it always remains there to agitate me once I start my bi-annually webspace spring cleaning.

I’m glad that the invention of “google” is available now. It is so useful that within minutes of researching I found the answers to my problem. Some people say that this particular problem often happen within shared hosting accounts. The server basically gets mixed up with the different users and something goes wrong (I think. Not sure if I comprehended correctly). There are two ways to solve this, call your service provider asking them to delete it. OR, follow the method I have used for myself.

Basically these files becomes undeletable for you do not have the permissions to do so. For some reason the permissions of this files get messed up and viola, you can’t delete them. However, the power of php comes to save the day. A simple php file helps you to alter these permission of the files allowing you to once again take ownership of them.

<?php
   function rchmod($parent, $dmod, $fmod) {
         if (is_dir($parent)) {
                 $old = umask(0000);
                 chmod($parent, $dmod);
                 umask($old);
                 if ($handle = opendir($parent)) {
                         while (($file = readdir($handle)) !== false) {
                           if ($file === "." or $file === "..") {
                                         continue;
                                 } elseif (is_dir($parent . '/' . $file)) {
                     rchmod($parent . '/' . $file, $dmod, $fmod);
                                 } else {
                                         $old = umask(0000);
                                         chmod($parent . '/' . $file, $fmod);
                                     umask($old);
                                 }
                         }
                         closedir($handle);
            }
         } else {
                 $old = umask(0000);
                 chmod($parent, $fmod);
                 umask($old);
         }
    }
    rchmod('thestupidfoldernamethatdoesnotletyoudelete/', 0777, 0666);
?>

You just have to upload this php file into the folder where the item you want to delete lies. For example it is the folder name “delete” in /usr/polar/swiftworld/swift/delete, you have to upload your php file within /usr/polar/swiftworld/swift/. You then run the php file and it will change the permissions for that folder and the contents within. You just have to change the folder name within that script and add additional lines if you want to change the permissions of more than one file.
Have fun and hope that it helps you. Remember to delete the file after using for now you know php files are so powerful, god knows what happens when bad people gets their hands on them.
Credit goes to the drupal community where the solution was found.

No votes yet.
Please wait...

10 thoughts on “550 Permission Denied Deleting Solved”

  1. WoW, I can’t believe this worked, thanks a lot!! 😀

    No votes yet.
    Please wait...
    1. No problem! 🙂

      No votes yet.
      Please wait...
  2. Wow,

    Thank you, Thank you.

    It works smashing.

    grtz.

    No votes yet.
    Please wait...
  3. Don’t you hate it when the answer is simple – but you couldn’t work it out for yourself. Thanks guys

    No votes yet.
    Please wait...
  4. Oh, I see – it worked. At first it didn’t seem to and I got a couple error messages, but then I was able to go back in with ftp and delete the folder (after all this time).

    Like you, I had named it “please delete me”.

    Thanks, I have saved this for future use.

    No votes yet.
    Please wait...
    1. Glad that it worked! It sure was irritating for me to have an unwanted undeletable file in my site.

      No votes yet.
      Please wait...
  5. So…. dumb question. How do I run the script?

    No votes yet.
    Please wait...
    1. You run the php file, in other words access it via your web browser.

      So say you uploaded it to your main index called delete.php, you would use your web browser to navigate to http://yourwebsite.com/delete.php

      Hope that helps!

      No votes yet.
      Please wait...
      1. Ah! Ok!

        I’d actually tried that, but since I was trying to use it on a wordpress plugin and had put the script in the plugins folder, I think that screwed it up (so when I entered the address of the script I got my webpage with a “404 not found” message.

        Moving the script to the main directory and editing the folder location to point to the plugin directory did the trick.

        Thanks!

        No votes yet.
        Please wait...
  6. Very cool. Worked like a charm.

    No votes yet.
    Please wait...

Leave a Reply to Ryan Cancel reply

Your email address will not be published. Required fields are marked *