I am a software developer so I am not so into operating system configuration details and I have the following problem.

I have installed a LAMP environment of an Ubuntu Linux system dedicated to the develop (it is on my PC and it is not a production server).

So I am trying to set the /var/www as the workspace of Aptana (the IDE that I use for PHP develop) but I can't do it because I have not the permission to write in this directory (I think that it is my logged user that have not this permission).

So I know that probably I can solve this issue simply changing this permission by:

sudo chmod -R 777 /var/www/

I think that it makes readable, writable and executable anything that it is into the /var/www/ directory, is it right? But for who? For every user that can be registered on my system or only for the logged user?

Reading online it seems to me that (maybe, I am absolutly not sure) I can obtain the same result (write into the /var/www/ directory) by doing something like:

sudo chown -R myUserName:www-data /var/www/
sudo chmod -R g+s /var/www/

Is these 2 commands true for my pourpose? What exactly does? I am trying to read the official documentation and it seems to me that works in this way:

  1. First I set my user as the owner of the /var/www/ directory (so it means that it can write into this directory and in all subdirectories because use the -R parm?) and assigns the www-data group. But what is this www-data group? Is it a standard Linux group or is a new group that simply can group member?

  2. I really have no idea about what exactly does the second statment. What it does?

What solution are better?

  • Have you tried asking this question on: askubuntu.com ?
    – Andrew
    Apr 27, 2015 at 12:35
  • Usually a programmer prefers to have a development environment as close as possible to the final one. I did not suggest you to set www with chmod 777. You can read many other reason to avoid it e.g. from here.
    – Hastur
    Apr 27, 2015 at 17:58

1 Answer 1


Basically the first command:

sudo chmod -R 777 /var/www/

Makes it readable, writable and executable by anyone (any user). You are on the right track with the latter commands, as you can set chown to www-data. www-data is a default user/group for Apache.

Or you could create a new group and add yourself and www-data there, then assign the group to the folder permission with chown.

Also instead of using numeric chmod values, you can use chmod -R ugo+rwx folder which means that give user, group and others => read, write and execute rights to this folder. Similar way you can also remove rights chmod -R ugo-rwx folder.

Setting directory with g+s makes all new files created in said directory have their group set to the directory's group.

You must log in to answer this question.

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