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 have not been able to set a umask for www-data (apache's user).

I tried to put umask 002, like in many other examples I found, in /etc/init.d/apache2 script, or in /etc/apache2/envvars.... Then I restart my apache server.

As an example, after restarting, if I do:

sudo su - www-data
touch file

The file gets always the default rw-r--r-- permissions (umask 022), while I want rw-rw-r-- (umask 002).

Changing this has been up to now an impossible task in Ubuntu Hardy (8.04).

Can anybody help me please ?


share|improve this question
Please review your old questions with answers, accept any valid answers. If there are no valid answers, then add comments or update your questions so that someone can provide valid answers. – Zoredache Mar 29 '12 at 20:13
up vote 3 down vote accepted

The umask is specific to a process, not to a user. For example, setting the umask in /etc/init.d/apache will likely make files created by apache umask 002 (assuming the process doesn't enforce specific permissions, or change the umask after you configure it in the init.d script).

However, when you sudo su - www-data, you're not setting a umask in any of the files you've sourced into your shell. You're getting the default umask at this point.

share|improve this answer
indeed, I did a little php program to write a new file and it set correctly the group permissions... – arod Mar 29 '12 at 21:02
"The umask is specific to a process, not to a user" : so why then is it possible to adapt the umask to a specific user in /etc/.profile ? – hornetbzz May 10 '12 at 17:11
Sure, you can adjust the configuration of /etc/profile to set the umask for a particular user, but it only takes place for the processes created after that change is made. Other processes that are already running have their own umask - regardless of the changes you make elsewhere or running the 'umask' command after starting a shell, etc. – Kyle Smith May 10 '12 at 19:40

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.