Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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've been told I need to set some file permissions for my php scripts. how do I do this so I can set a file to something other than 006 permission? (right now, only 006 works).

The main question is, how do I make a group?

share|improve this question
You need to provide more information. Which user is PHP running as? What are the user and group for the files in question? You can find out with ls -al filename - the third and fourth column should show you the user and group. Also, I really doubt 006 is the only permission set that works. It means that everyone can read and write to the file except for the user and group. Typically, the webserver shouldn't be able to write. – James L Jan 20 '11 at 23:28
I tried your codeline, it says root root – david19801 Jan 20 '11 at 23:30
chmod 644 - gives rw-r-r
chmod 755 - givex rwx-rx-rx

006 it will be useless ... since the user and the group can't read the file but allows everybody to read and write - perhaps is the other way around 600

chmod 006 - gives - - rw
chmod 600 - gives rw- -
share|improve this answer
Funnily enough, if the file is root:root and the webserver is (hopefully) not root, 006 will work. Insecure, but it will work. – James L Jan 20 '11 at 23:43
Yes, that seems to be my situation, how would I correct it to make it proper secure? – david19801 Jan 20 '11 at 23:58
  • Create a development group. The syntax will differ based on what flavor of *nix you are using: groupadd dev, for example.
  • Make sure both the user you are logged in as (which should not be root) and the web server user are part of that group: useradd -G dev david; useradd -G dev apache
  • Make sure the files in your web directories are owned by your web server user: chown -R apache:dev /path/to/dir
  • Change permissions for files and directories appropriately with chmod, making sure that the first two numbers match and give the full permissions but that the last number gives only the permissions needed for users to view pages (which is typically 'read' (4) or 'read/execute' (5))

PHP executed from your web server should be executed as your web server user, and PHP executed from your logged-in user should be executed as that user. As such, as long as your logged in user of 'david' is part of the 'dev' group (as 'apache' should be too) and all files are owned by apache:dev, you should be good to go.

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.