0

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

0

3 Answers 3

2

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).

2
  • 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, 2011 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, 2011 at 22:03
1

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.

2
  • 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, 2011 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, 2011 at 3:05
1

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).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .