My web server is running on Ubuntu Linux. The user www-data is able to create directories inside the /data/ directory but the permissions on a newly created directory is 345.

How can I make the default permissions for a directory created by the user www-data in /data/ 774?

  1. The folder owner is www-data and the user group is www-data.

  2. I've tried doing the following:

    sudo setfacl -dR -m g::rwx,u::rwx  /data/ 
    sudo chmod -R 774 /data
  3. Could it be umask related?

  4. My getfacl output is as follows:

    getfacl: Removing leading '/' from absolute path names
    # file: data/
    # owner: www-data
    # group: www-data
    # flags: -s-

How can I achieve this?

1 Answer 1


My answer would indeed be "umask". With umask you indicate what permissions should be removed. In your case, 3.

umask 003

www-data needs to set that before creating files or directories.

  • how would you set umask for specific user "www-data" per directory ? Thanks
    – Asma.Said
    Feb 19, 2018 at 9:45
  • It's not set "per directory". Once set, it's effective for all new directories and files created. For a normal user account, you'd set this in his profile. But www-data is a service user, a daemon. I suppose we're talking about Apache, httpd? What process is actually creating the new directories? Feb 19, 2018 at 9:56
  • yes it's Apache httpd, and it's using mkdir
    – Asma.Said
    Feb 19, 2018 at 10:47
  • I know Apache rather well, but still don't know how you could do a "mkdir", which is a shell command. Can you explain? Feb 19, 2018 at 14:16

You must log in to answer this question.

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