Jump to content

[Solved] Directory Removal


Guest Geoff

Recommended Posts

Account details:

 

username:gfishing

domain:geoffish.heliohost.org

 

 

Problem:

 

I cannot remove the directory "/home/gfishing/public_html/drupal". I get permission denied errors, and other related problems when attempting to remove the directory via CPanel or FTP.

 

This is really weird, because I have never had this problem before. Just trying to install CMS (don't trust softalicious), and I attempted to move my installation to my document root, but could not.

 

If you could just remove the directory above for me, everything should be fine, unless I get more similar problems.

 

Thanks,

 

Geoff

Link to comment
Share on other sites

I get the following error:

 

rm: cannot remove `/home/gfishing/public_html/drupal/sites/default/default.settings.php': Permission denied rm: cannot remove directory `/home/gfishing/public_html/drupal/sites/default/files': Permission denied rm: cannot remove `/home/gfishing/public_html/drupal/sites/default/settings.php': Permission denied

 

See for yourself here.

Link to comment
Share on other sites

The folder "public_html/drupal/sites/default" had its permissions set to 555, preventing you from deleting it. In addition, the files "settings.php" inside the aforementioned folder was set to 444. After correcting both these settings, I was able to delete the folder.

Link to comment
Share on other sites

Thanks

 

Edit: Here is the script for my own convenience if it is deleted:

 

<?php

function deleteDir($dir) {
   // open the directory
   $dhandle = opendir($dir);
   if ($dhandle) {
      // loop through it
      while (false !== ($fname = readdir($dhandle))) {
         // if the element is a directory, and 
         // does not start with a '.' or '..'
         // we call deleteDir function recursively 
         // passing this element as a parameter
         if (is_dir( "{$dir}/{$fname}" )) {
            if (($fname != '.') && ($fname != '..')) {
               echo "<u>Deleting Files in the Directory</u>: {$dir}/{$fname} <br />";
               deleteDir("$dir/$fname");

            }
         // chmod all directories and files correctly
         // the element is a file, so we delete it
         } else {
            chmod("$dir", intval(0755, 8));
            chmod("{$dir}/{$fname}", intval(0644, 8));
            unlink("{$dir}/{$fname}");
            echo "Deleting File: {$dir}/{$fname} <br />";
         }
      }
      closedir($dhandle);
    }
   // now directory is empty, so we can use
   // the rmdir() function to delete it
   echo "<u>Deleting Directory</u>: {$dir} <br />";
   rmdir($dir);
}
// call deleteDir function and pass to it 
// as a parameter a directory name
deleteDir("/home/username/public_html/delete");
?>

Link to comment
Share on other sites

Just incase that happens again I just modified this php script to recursively chmod all files and folders (including sub-folders & files) to the correct permissions and then delete folder and files (incuding sub-folders & files).

 

http://byrondallas.heliohost.org/temp/recu...files_chmod.txt

 

Be careful when runing this script. There is no recovering of files after the script is run.

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...