Help

File permissions and chmod 755 explained

chmod 755 lets the owner read, write and execute, and lets the group and everyone else read and execute only. On typical cPanel hosting, set folders to 755 and files to 644. Keep config files such as wp-config.php tighter, at 600, 640 or 440. Never use 777.

Updated · HostUpIndia team

What read, write and execute mean

Every file and folder on Linux hosting has three sets of permissions: one for the owner (your cPanel account), one for the group, and one for others, which means everyone else on the server.

ls -l shows them as nine letters, such as rwxr-xr-x: three for the owner, three for the group, three for others. A dash means that permission is off. cPanel File Manager shows the same as a number, such as 0755; you can ignore the leading 0.

  • Read (r): view a file, or list what is in a folder.
  • Write (w): change or delete a file, or add, rename and delete files in a folder.
  • Execute (x): run a file as a program, or open a folder and reach the files inside it.

What chmod 755 and 644 mean

Each permission has a number: read is 4, write is 2 and execute is 1. Add them up for each set. The three digits are the owner, the group and others, in that order.

  • 7 = 4 + 2 + 1 = rwx: read, write and execute.
  • 6 = 4 + 2 = rw-: read and write.
  • 5 = 4 + 1 = r-x: read and execute.
  • 4 = r--: read only.
  • 0 = ---: no access.
  • 755 is rwxr-xr-x: the owner can do everything, and the group and others can read and open, but not change.
  • 644 is rw-r--r--: the owner can read and write, and everyone else can only read.

The right permissions for a website

On most cPanel hosting, PHP runs as your own account. These settings let your site run while no one else can change your files.

  • Folders: 755.
  • Files, including .php, .html, images and .htaccess: 644.
  • Config files that hold passwords, such as wp-config.php: 600 or 640. Once you no longer edit it, 440 or 400, if your site still loads.
  • Scripts you run directly, such as CGI scripts in cgi-bin: 755.
  • Leave public_html itself as your host set it. On cPanel it is often 750.
  • Never use 777 or 666. Anyone on the server could change the file, and many servers refuse to run PHP that others can write to.

How to change permissions in cPanel File Manager

Back up before you change permissions on many files, and note the old numbers so you can set them back.

  • In cPanel, open Backup and download a home directory backup.
  • Open File Manager and go to your site’s folder, usually public_html.
  • Read the Permissions column to see each file’s and folder’s current number.
  • Select a file or folder, then select Permissions in the toolbar.
  • Tick read, write and execute for User, Group and World until the number reads 755 for a folder or 644 for a file.
  • Select Change Permissions, then load your site.

How to chmod over SSH

To fix a whole site at once, open Terminal in cPanel, or connect with an SSH client using the details in your welcome email or client area.

  • Go to your home folder: cd ~.
  • Back up first: tar -czf site-backup.tar.gz public_html. This saves a copy of your files, with their permissions, outside public_html.
  • Change one item: chmod 755 public_html/images for a folder, or chmod 644 public_html/index.php for a file.
  • Set every folder inside public_html: find public_html -mindepth 1 -type d -exec chmod 755 {} +.
  • Set every file: find public_html -type f -exec chmod 644 {} +.
  • Lock WordPress’s config again: chmod 600 public_html/wp-config.php.
  • Set any CGI scripts back to 755.
  • Check with ls -l public_html: folders show drwxr-xr-x and files -rw-r--r--, except wp-config.php at -rw-------. Then load your site.
  • Avoid chmod -R 755. It makes every file executable too.

403 Forbidden and 500 errors from wrong permissions

Most permission errors come from a setting that is too tight for the web server, or too open for PHP.

  • 403 Forbidden: the web server cannot read a file or open a folder, often one set to 700 or 600. Set folders to 755 and files to 644.
  • 500 Internal Server Error: some servers refuse to run PHP from a file or folder others can write to, such as 777. Set folders back to 755 and files to 644. For other causes, see how to fix the WordPress 500 error.
  • In cPanel, open Errors under Metrics to see which file the server refused.
  • “Unable to create directory” in WordPress: set wp-content/uploads and the folders in it to 755.
  • Still blocked? The files may belong to the wrong owner, which you cannot change from cPanel. Open a support ticket.

HostUpIndia Web & cPanel Hosting

HostUpIndia Web & cPanel plans include cPanel with File Manager and terminal (SSH) access for the steps above, on LiteSpeed with NVMe storage and free SSL. Daily backups kept 30 days give you a restore point if a change goes wrong.