Linux – How to set default group permission in Ubuntu for www-data (apache’s user)

apache-2.2linuxUbuntuumaskwww-data

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 ?

Thanks

Best Answer

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.