File and folder permissions, and why 777 is never the answer

Every file and folder has permissions controlling who may read, write and run it. When something does not work, "set it to 777" is common advice on the internet. It is bad advice, and on our servers it will usually break the thing it was meant to fix.

The correct values

  • Files: 644. You can read and write them; everyone else can read.
  • Folders: 755. As above, plus the ability to list the contents.
  • Scripts you run yourself over SSH: 700 or 755.
  • Configuration files holding database passwords: 600 where the application allows it.

Why not 777

777 means anyone at all may write to it. On a shared server that is an obvious risk, but more immediately: our servers run your site as your own user, so your site already has all the access it needs at 644 and 755. Setting 777 adds nothing you need and the server will often refuse to execute the file at all, producing a 500 error. It is a common cause of the very problem people apply it to solve.

Fixing permissions in bulk

cPanel's File Manager can apply permissions recursively: select the folder, choose Permissions, and apply to files and folders separately – 644 for files, 755 for folders. Do not apply one value to both.

Files uploaded by the website

Files created by your site – uploaded images, generated caches – are owned by your account and will be correct automatically. If you have uploaded files as root over SSH, or extracted an archive created elsewhere, ownership can end up wrong; ask us and we will correct it.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Recognising a phishing email that claims to be from us

Hosting customers are a standard target for phishing, because an attacker who gets your control...

My website has been hacked: the first things to do

Work in this order. The instinct is to delete the bad files and carry on, which is exactly how...

Turning on two-factor authentication

Two-factor authentication means that knowing your password is not enough to get in. It is the...

Why we block IP addresses, and how to get unblocked

Our servers block addresses automatically when they behave like an attack. This is not a...

Choosing and managing passwords

Most compromises we see come down to a password that was weak, reused, or stolen from somewhere...