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

I used

adduser <name>

and created a new user, andrew. Now I want to give him read/write access only to /var/www/ and its contents.

How am I supposed to do this?

I tried sudo chown andrew /var/www/ but he is still able to see all the folders and files under /var/www and other directories.

share|improve this question
I have marked this question as a duplicate of this question. Though the question is not identical, I think the answer fits quite the same. – zwets Aug 10 '15 at 9:00
up vote 4 down vote accepted

Changing the ownership to a designated user will not change the users default home directory specified in passwd file. Anyhow, You may achieve this in different ways. But to make it simpler do this by opening up a terminal;

Firstly make a back-up of your /etc/passwd file doing below;

sudo cp /etc/passwd /etc/passwd.back

Once done, edit the file (either with vi or nano), I prefer nano which is pretty easy;

sudo EDITOR=nano vipw /etc/passwd

Locate the created user. A line should reflect as below assuming the user is andrew;


Replace /home/andrew with /var/www/ & save the file by hitting CTRL+O then enter to save & then CTRL+X to exit. This will direct the user to specified directory. Login as the user and see whether it points to **/var/www/ by also checking for any permission issues. If permission issue persists, then add the user to the www-data group by doing below;

sudo adduser andrew www-data

EDIT: regarding the comment, I just had a quick search and found some more detail. Well, you may edit vsftpd.conf file located in /etc/ directory

sudo nano /etc/vsftpd.conf

un-comment (remove only the # if its there at the beginning) the following line;


Note: Just to be safe, make a back-up of the configuration file before you make any changes to it.

sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.back

Source: vsftpd.conf on Ubuuntu

Hope it helps!

share|improve this answer
it works, but I still can access other folders – Vladimir Stazhilov Jan 27 '14 at 15:13
that is because the user is also in www-data group too.. – AzkerM Jan 27 '14 at 16:17
@VovaStajilov, I had a quick search added few more in-detail by editing. I hope it may help you. – AzkerM Jan 27 '14 at 16:51

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.