I have web files stored on my server. Currently only the root has a full access:

drwxr-xr-x  6 root www-data  directory
-rw-r--r--  1 root www-data  file.php

The problem is that the developers wants to use their own account su - myuser to access and modify these files.

Unfortunately, the only solution I have found is to add these users to www-data group and make the php files writable by www-data which is ugly.

What alternative do I have?

  • Why are the developers modifying files on a production server? You should have at least a development server and maybe a staging server as well.
    – DavidPostill
    Jun 27, 2018 at 8:47
  • This is rather a development server than a production server, but the files get their permissions from the Git repository.
    – nowox
    Jun 27, 2018 at 8:48
  • The other solution (of a dev server) is to put the files in the same groups as developers, with read-access by the server. Unless the server needs write access to its own files but this is even more ugly...
    – xenoid
    Jun 27, 2018 at 11:34

2 Answers 2


I believe you need to use X and not x for the executable.

Step 1: Create Backup

First make a backup incase anything goes wrong someday:

mkdir ~/storage-changes
sudo getfacl -R /var/www > ~/storage-changes/default_www_facl

(Incase) To Restore

sudo setfacl --restore=~/storage-changes/default_www_facl 

Apply ACL

Next, apply to a group:

# -R is recursive
# -m is modify
# -d applies to default ACL

sudo chgrp -R www-data /var/www
sudo setfacl -Rd g:www-data:rwX /var/www
sudo setfacl -Rdm g:www-data:rwX /var/www

ls -lta /var
sudo getfacl /var/www

The + at the end of the file/dir listing only means it has additional ACLs.


If your Linux server isn't too old, and you are on a standard filesystem for Linux, you can use access control lists to give permissions to other users.

For example, the following command will give read and write permissions to the myuser user on file: setfacl -m user:myuser:rw file

setfacl may need to be installed, depending on your distribution.

You must log in to answer this question.

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