Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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

This question already has an answer here:

I have downloaded Apache on Ubuntu by following this tutorial. It installed the Apache nicely and it is running successfully but there is one problem which is a huge one. I do not have permissions to Write to /var/www folder although I am Administrator. The current owner of that www folder is root. I have installed Ubuntu today so I don't know much about it. I have used chown command but it throws error : Operation not permitted.

Can anybody tell me so that I can have Read & Write permissions?

share|improve this question

marked as duplicate by Lekensteyn, Rinzwind, Alaa Ali, Kevin Bowen, guntbert Sep 6 '13 at 8:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

"I have used chown command but it throws error : Operation not permitted." your forgot to put sudo in front of your command. And the user and group of things inside /var/www/ should not be root but apache or www-data ;) (see the apache.conf or sites-enabled for the correct one). – Rinzwind Sep 5 '13 at 13:07
@Rinzwind Hey, man I am reading docs. Read about sudo, gives us Super User priviliges. Let me run the command ;) – Muhammad Talha Akbar Sep 5 '13 at 13:11

open your terminal and type as

chmod 744 -R /var/www/

I have faced the issue too and resolved by the above command. hope that helps.

Only root user have complete permissions. Normal user and others are only able to read and can not able to write or execute.

Next with

chmod 754 -R /var/www/

root can do everything. Normal user can read and execute but can not write. other user can read but can not write and execute.

share|improve this answer
This leaves potential security issues. – Joren Sep 5 '13 at 13:37
other can read and execute but they cant write , so what the problem ? – Raja Sep 5 '13 at 13:39
this makes unix command injection possible – Joren Sep 5 '13 at 13:40
@Joren now ok ? – Raja Sep 5 '13 at 13:45
I agree with @Joren And to nitpick even more: 664 is -more- than enough for not executables. So *html, *js etc need not be 754. (and yes I am paranoid too ;) ) – Rinzwind Sep 5 '13 at 14:43

It is not advisable to change the ownership of the /var/www folder, leave it as root. If you need to create new files or folders inside /var/www leave them also under root ownership; or owned by you user if you prefer. For Apache to serve these assets all you need to do is provide read permissions to the www-data user:

sudo chmod a+r /var/www/my.asset

Also, consider using instead the /srv folder to store assets that must be served by applications such as Apache.

share|improve this answer

You can access the files in /var/www/ easily by using nautilus as root:

sudo nautilus

I would not recommend changing ownership or permissions of the directory because of potential security risks.

share|improve this answer

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