Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I discovered some of my htaccess files had the file attribute "777". It was changed by a bot i think and redirected my site. I have now set it to "644" which should be safe (or please correct me).

I realised that most of my php files has the attribute 777, is this normal or should they be 644 as well ?

Thank you

share|improve this question

migrated from Oct 1 '11 at 11:46

This question came from our site for professional and enthusiast programmers.

up vote 2 down vote accepted

Chmod 664 means:

  • The owner of the file has read and write access
  • The users who belong to the same group have read and write access
  • Other users have read access

An overview of permissions:

  1. Execute
  2. Write
  3. Write + Execute
  4. Read
  5. Read + Execute
  6. Read + Write
  7. Read, Write, Execute

Normal files should never get execute permissions, so either use 2, 4 or 6. Unknown users shouldn't be able to write in your file, so, 4 is the only option left for them.

Folders need Execute permission, so that files can be written. It's recommended to set the permissions of a folder to 555.

The three numbers represent Owner, Group and All (as mentioned earlier).

share|improve this answer
i just changed all my files to 644, now i got a big problem, when i try to access the site it gives me 403 forbidden – 2by Sep 23 '11 at 22:00
Did you also apply chmod 644 to your folders..? If yes, run chmod 555 on your folders to fix it. – Rob W Sep 23 '11 at 22:03
Thanks :) Ran 755 on folders – 2by Sep 23 '11 at 22:08

For web browsers to read your .php files all you need is 644 (you may be able to get away with tighter permissions). Having your files as 777 is very dangerous. In fact I can't think of any reason why you would want anyone to be able to edit your files.

share|improve this answer
thanks @user961861, but what about images and folder? Can i just mark all the files and set it to 644 and there should be no problems ? – 2by Sep 23 '11 at 21:55
you should be able to set everything to 644 and have no problems. just to be sure though, back up your files and make sure to note what you change so if there are any errors you can go back and fix it. – nick Sep 25 '11 at 3:05

The 777 are the file permissions of the file for a *nix based operating system. The rule of thumb is keep the access as minimal as you can; only give users access that need it. It sounds like reading up on file permissions would be worth your while.

The .php files you have do not need to have a 777 permission (this is giving all users read, write and execute access to the php file).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.