Pre-requirements
- Access to your cPanel account.
- Familiarity with basic Linux commands if using the terminal.
- Ensure you have a backup of any important files before deleting folders.
Why Can't You Get Root Access?
Root access is reserved for users with private virtual servers (VPS) or dedicated servers. If you are on a shared hosting plan, root access is not available. However, you can still manage your files using cPanel's File Manager or Terminal.
How to Delete Folders Recursively in cPanel Using the Terminal
Follow these steps to remove a folder and its contents using the cPanel Terminal:
- Log in to your cPanel account.
- Scroll to the Advanced section and click Terminal.
- Once in the Terminal, find your current directory by typing:
pwd
- To delete a folder and all its contents, use the following command:
Replacerm -rf folderName
folderName
with the actual name of the folder you wish to delete. - If the folder is located in your public_html directory, use either of the following commands:
cd public_html && rm -rf folderName
or:
rm -rf public_html/folderName
- Once you're done, exit the terminal by typing:
exit
Gotchas to Avoid
- Be cautious when using the
rm -rf
command, as it will permanently delete the folder and its contents without asking for confirmation. - Ensure you're in the correct directory to avoid accidentally deleting critical files or folders.
Deleting Folders Using cPanel's File Manager
If you're not comfortable using the terminal, you can delete folders directly from the cPanel File Manager. Here's how:
- Log in to cPanel and go to File Manager.
- Navigate to the folder or file you want to delete.
- Select the folder and click Delete from the toolbar. A confirmation prompt will appear.
- Click Confirm to move the folder to the Trash.
Restoring Deleted Files from Trash
If you accidentally deleted a folder, you can restore it from the Trash. Here's how:
- In the File Manager toolbar, click View Trash.
- Select the file or folder you want to restore.
- Click Restore to recover the deleted item.
Emptying the Trash for Permanent Deletion
Deleted items are not permanently removed until you empty the Trash. To completely delete the files:
- In the File Manager toolbar, click Empty Trash.
- Confirm that you want to permanently delete the files from the Trash folder.
Gotchas to Avoid
- Ensure that you're certain about the files being deleted before emptying the Trash. Once deleted from Trash, they cannot be recovered.
- Clearing the Trash can be useful before backing up your account to save space.
Additional Help
If you are unable to delete a folder via the Terminal or File Manager, or if you are facing any errors, feel free to open a support ticket with your hosting provider. You can provide them with the folder name, and they will assist you in removing it.
If you want to add to this tutorial or have found an error in it, please send an email to team+editorial@webhostingm.com