Personal Life

All about my world, word and story. Of course including my bear, Polar.

Review

Games, movies, software etc reviewed by Polar and me. All based on opinions on facts and personal likings.

Website

Web apps, interesting links etc Everything about the Websites found in the Internet.

Gaming

My gaming addiction is described here. Contains latest news and information on the gaming scene.

Video

Funny interesting new innovative creative sporty and everything that is nice to see. Basically videos that interest me so much that I think it may appeal to you as well.

Home » Website

550 Permission Denied Deleting Solved

Submitted by on September 21, 2009 – 1:40 am9 Comments

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?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.

VN:F [1.9.17_1161]
Rating: 5.0/10 (2 votes cast)
VN:F [1.9.17_1161]
Rating: +1 (from 1 vote)
550 Permission Denied Deleting Solved, 5.0 out of 10 based on 2 ratings
Be Sociable, Share!

Other articles that might interest you

9 Comments »

  • MuMu says:

    WoW, I can’t believe this worked, thanks a lot!! :D

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.17_1161]
    Rating: 0 (from 0 votes)
  • Pete says:

    Wow,

    Thank you, Thank you.

    It works smashing.

    grtz.

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.17_1161]
    Rating: +1 (from 1 vote)
  • Don’t you hate it when the answer is simple – but you couldn’t work it out for yourself. Thanks guys

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.17_1161]
    Rating: 0 (from 0 votes)
  • Chris says:

    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.

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.17_1161]
    Rating: 0 (from 0 votes)
  • Jon says:

    So…. dumb question. How do I run the script?

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.17_1161]
    Rating: 0 (from 0 votes)
    • Swift says:

      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!

      VN:F [1.9.17_1161]
      Rating: 0.0/5 (0 votes cast)
      VN:F [1.9.17_1161]
      Rating: 0 (from 0 votes)
      • Jon says:

        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!

        VA:F [1.9.17_1161]
        Rating: 0.0/5 (0 votes cast)
        VA:F [1.9.17_1161]
        Rating: 0 (from 0 votes)

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.