Permission denied when deleting files: how to fix file permissions
PrintWhen File Manager or your FTP program answers "Permission denied" as you try to remove something, the item is protected by its permissions, and most often by the permissions of the folder that holds it. You can usually fix this yourself in a minute: give the containing folder the value 755, delete the item, then check that the rest of the site still has the usual values.
Why the server refuses to delete
On a Linux server, removing a file is a change to the folder it sits in. What matters is therefore whether that folder is writable for your account, not only the file itself. The usual situations are:
- A security plugin or a script has made files or folders read-only, with values such as 444, 555 or 400.
- An archive was extracted with odd permissions, or someone set a folder to 000 to hide it.
- The file belongs to a different system user, for example after a manual restore by an administrator. Such a file cannot be changed from your account.
How to read permission values
Every file and folder has three digits. The first one applies to the owner (your cPanel account), the second to the group, the third to everyone else. Each digit is a sum: 4 is read, 2 is write, 1 is execute, which for a folder means the right to enter it.
| Value | In letters | Use it for |
|---|---|---|
| 755 | rwxr-xr-x | folders |
| 644 | rw-r--r-- | ordinary files: PHP, HTML, CSS, images |
| 600 or 640 | rw------- or rw-r----- | configuration files that hold passwords, such as wp-config.php |
Avoid 777. Giving everyone write access is a security risk, and many server setups will not run a script from a file or folder that anyone can write to, so the page ends with an error 500.
Fixing it in cPanel File Manager
- Log in to cPanel and open Files, then File Manager.
- Browse to the item that cannot be deleted and look at the Permissions column, both for the item and for the folder above it.
- Go up one level, tick the containing folder and click Permissions in the toolbar. Enter 755 and confirm with Change Permissions.
- Open the folder again, tick the item and click Delete. If the item is itself a folder with 555 or 000, give it 755 first, otherwise its contents cannot be removed.
Items deleted in File Manager land in its trash and keep using disk space. Empty it with View Trash, then Empty Trash, or tick Skip the trash and permanently delete the files in the delete dialog if you are sure.
Fixing it with FileZilla or another FTP program
- Connect to your hosting account (the setup is described in Setting up FileZilla).
- Right-click the folder that contains the item and choose File permissions....
- Type 755 in the Numeric value field, click OK, then delete the item.
If a plugin has locked a whole folder tree, tick Recurse into subdirectories and choose Apply to directories only with 755. Run the dialog a second time with Apply to files only and 644. The Owner/Group column in FileZilla tells you which user owns each file.
Using Terminal
If your account has Terminal or SSH access (see Connecting to the server via SSH), the same check takes two commands. The first lists permissions and owners, the second unlocks a folder:
ls -la chmod 755 folder-name
Still refused?
- Another owner. If the owner shown is not your cPanel username (for example root or nobody), only our team can change it. Open a ticket and give the full path of the file.
- The lock comes back. Some WordPress security plugins reapply read-only permissions on their own. Turn off the file protection option in the plugin first, then delete.
- Odd file names. Names with a space at the end or unusual characters sometimes cannot be handled in File Manager. Rename or delete them from an FTP program instead.
If none of this helps, write to us at https://billing.tophost.md/submitticket.php with the path and the exact error message.
After the clean-up
Put the permissions back to the normal values: 755 for folders, 644 for files. If you are deleting to win back space or to cut the number of files, these guides help you choose what can go: Disk space running out and Too many files (inodes) in your account.