Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

When I try to place my web files into /var/www in apache on my ec2 Ubuntu instance it is giving me an error stating that I don't have permission.

Permission denied.
Error code: 3
Error message from server: Permission denied
Request code: 3

How do I give myself permission to do this or what is the best way to copy files to /var/www with WinSCP?

share|improve this question

I was getting the same error in WinSCP. One solution is to change the ownership of the '/www/' folder using chown. That way, you can make the user you log in with into the owner instead of 'root' being owner. I am using an instance of Amazon Linux rather than Ubuntu, but this command worked for me:

sudo chown -R -v ec2-user /var/www/

The user 'ec2-user' is the user I log in with.

Potentially Useful links

share|improve this answer
Your requests for help as part of an answer to someone else's question is likely to not get any responses or helpful feedback. To get that, you're probably better off asking your own question with the precise details you're needing. – killermist Mar 28 '13 at 2:33

Enable write permissions for the user logging in thru WinSCP. There are two ways to do this.

The first way is to change the permissions on the folder to allow anyone to write to it. This isn't the best security.

chmod 777 /var/www

The second way is to add your user to the group owning the directory, and then setting permissions for the group to write to the directory.

Find out who owns the directory:

ls -l /var | grep www

You'll see something like: drwxr-x--- 9 www-data www-data 4096 Jul 14 2009 www The important thing to note are the two names root and root. In this case, the owner of the directory is www-data, and the group of the directory is www-data. So now you'll add your user to group www-data.

usermod -G www-data user

Now just add the write permission to the group.

chmod 770 /var/www


ls -l /var | grep www

should return: drwxrwx--- 9 www-data www-data 4096 Jul 14 2009 www

With this you'll be able to write to the directory, while not opening up write privileges to everyone.

share|improve this answer
slight correction for exactness - sudo chmod 777 /var/www - sudo usermod -G www-data (username) - sudo chmod 770 /var/www - It may work depending on who you are in your example, but 'sudo' should work no matter who you are (assuming your login is in /etc/sudoers for root/admin of course). – bshea Sep 25 '13 at 16:32
Thanks it worked like a charm for me. – Anil Chahal Jun 5 '15 at 9:22

You need to give the user write permissions, remember the previous permissions using stat /var/www.

Then you can change them withsudo chmod 666 /var/www and change them back later when needed.

Consult man chmod and man sudo alongside other file permission manuals on the internet for more info...

share|improve this answer

on ec2 this works for me. login to box via putty with user "ec2-user" and use commands :

sudo root
chmod 777 <NAME_OF_FOLDER>

Note : this grants write access for all users.

Should now be able to write using WinScp.

share|improve this answer

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.