Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I think I have screwed up my permissions in Ubuntu.

I am using my server to run PHP. I recently ran across a problem where PHP could not create directories in the var/www-directory, so I searched around on the internet. Now PHP can write and access anything like it should, but as a user, I can't create new folders or files anymore.

Right now, the permissions for folders are like this:

drwxrwsr-x 2 www-data www-data [Folders]

This is the permissions when I upload using sftp:

-rw-rw-r-- 1 gautvedt www-data [Folders]

What have I done wrong and how can I change this?

share|improve this question
up vote 8 down vote accepted

You need to include yourself into the www-data group.

Graphical method

Command line:

sudo adduser gautvedt www-data

That way you can add things to directories where www-data owns the group.

There are more methods but this is the easiest one.

share|improve this answer

After add user to www-data group as mentioned by Rinzwind, you should change the permission to 755

sudo chmod 0755 -R /var/www

without changing permission, it can't be accessed (forbidden). So, it will change to

drwxr-xr-x 1 gautvedt www-data [Folders]
share|improve this answer
To me anything that does not need executing should be set to 644 and not 0755 ;) – Rinzwind Oct 30 '12 at 11:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.