I have this ubuntu web server and I want to give permissions to access only by http but I don't want the folder to be visible to the network users. I have a subfolder were users upload some files and I want to hide that too. Can I do it with CHMOD? How?

3 Answers 3


By default, Apache on Ubuntu runs as www-data.

Let's assume your folder is located in /var/www/mysite.

You can do this:

chown -R www-data:www-data /var/www/mysite
chmod -R og-r /var/www/mysite

After doing this, www-data (the Web server) will have full access to the site's files, while other non-root users will have no access at all.

If you wish to allow select users to access the site, you can make the folder group-readable and add those users to the group www-data.

  • 1
    I try chmod 711 to mysite and worked. Commented Jul 25, 2013 at 10:45
  • I'v try @Carster solution and when I access my http page I get a blank page Commented Jul 25, 2013 at 10:49
  • Strange. Are you running Apache as web server? The specific commands I wrote will only work if your web server is running as www-data. Commented Jul 25, 2013 at 12:13

Probably what will work is running your webserver under a dedicated user, have that user be the owner of the folder, and then chmod 700 the folder.


chmod 711 Worked for me. I found this useful tool that help me a loot understanding CHMOD http://www.javascriptkit.com/script/script2/chmodcal.shtml

You must log in to answer this question.

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