From years, I am trying to fake I know how unix permissions works, but In fact, I don't understand anything.

www-data is the apache2 user My own user is my_user, it's having sudo access I am using root by using sudo su -

www-data is having all permissions on /var/www/html/ (755 www-data:www-data)

I can not connect as www-data and I want to PhpStorm to deploy on this server, using my_user.

So, by default, all folders are r-x, so I allow www-data's group to have full access (As root)

chmod -R g+rwx /var/www/html/project/themes

Then I add my user to this group (As root)

usermod -a -G www-data my_user

Now, logged my_user and phpstorm deployment are still returning "Permission denied". I disconnect my user, reconnect it and now this is working... What's going on dude ? So, I restart PhpStorm and this is working now.

I pushed my new folder on the server and I am now listing files

ls -la /var/www/html/project/themes

drwxrwx--- 2 my_user my_user 4096 Feb 15 09:51 new-folder

Wow buddy, I really need www-data to be able to read it, and edit it, and run it... I would like the new folders and files are owned by www-data:www-data to get it work. But maybe I am wrong ...

So, what is the best and definitive solution about these permissions issues ?

  • Or unix.stackexchange.com/questions/12842/…
    – muru
    Feb 15, 2022 at 10:23
  • @muru So you are considering I should use ACL, I already use it for some other projects but I would like to do that using chmod as, for me, it seems a basic need, isn't it ?
    – Loenix
    Feb 15, 2022 at 10:28
  • 1) g+s on dir should be enough 2) if files are rwxrwx--- even own by my_user , www-data should be able to edit/delete them ?
    – Archemar
    Feb 15, 2022 at 10:57
  • Yes but it should do it by default, the group is my_user by default instead of www-data. How to tell system to set new files' default group to another one ?
    – Loenix
    Mar 17, 2022 at 8:15

1 Answer 1


So Unix/Linux permissions work according to numbers and addition, okay? It's pretty simple once you understand this. Permissions-wise, you can have three possible permission rights and in any combination: read (notated as r), write (notated as w) and execute (notated as x). These are the alphabets that appear in the left-hand-side column that appears when you type ls -l into the terminal.

Now, whom do you give these permissions, though? Who has these permissions, and how are these viewed? Well, you again have three classifications:

  1. User (that is, the user who owns it, i.e. that created/took over the file)
  2. Group (the group of users to which the file belongs)
  3. Others (users who are not in the file's group)

Now, for the sake of assigning and modifying these permissions, these alphabets have also been assigned numbers:
r = 4
w = 2
x = 1
Before I try to explain the purpose of this, let me explain directly how that works instead, yeah? So, say, you have a file called file.sh, okay? You want to give it some permissions, and you are superuser and are trying to define the permissions for ugo, in that order, because that is convention. You can go rwx, but then what if you wanted to give only reading and writing rights to the user, but not execution permission to anyone? What if you wanted to give only reading and executing permissions, but not writing permissions (read-only executable), what then? This is when numbers come into play.
r = 4
r + w = 6
r + x = 5
r + w + x = 7
So, if you wanted to give say, reading and writing rights to everyone (ugo), you go
$ chmod 666 file.txt.
You want to give reading and execution rights to everyone, you go
$ chmod 555 file.txt.
You want to give read-only rights to everyone, but all rights to the owner, you go
$ chmod 744 file.txt.
You want to give all rights to everyone, you go
$ chmod 777 file.txt
The numbers 666, 555, 744, 777 are always in the order ugo: user-group-others.

You can also add individual permissions using +r, +w, and +x and remove by using -r, -w, and -x, though that is a more labourious process, as you seem to be doing.

I would suggest you solve your problem by going into the directory and just doing a
$ chmod 777 *
and giving all permissions to everyone. It's a crude and somewhat unsafe fix, but it works every time for such a problem, and would solve your problem till you figure out whom not to give these permissions and then retroactively remove those permissions from them.
Hope this helps.


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