I made mistake when use Chown command. I write

sudo chown /var/www/html/htaccess.txt www-data:www-data

insted of

sudo chown www-data:www-data /var/www/html/htaccess.txt

The answer was -

enter image description here

So - All my stuff from /var/www/html disappeared, and my site

You don't have permission to access / on this server.
Apache/2.4.7 (Ubuntu) Server at www.a-r-c-h.net Port 80
  • PLEASE - HELP!! How can I return it back?
    – Igor_77
    Oct 21 '16 at 17:51
  • 3
    your 1st command cant have done anything... there is not a file "www-data:www-data" so nothing got changed... please add results from ls -l for /var/www/html/ edit: looked at the image now :D see! it shows an error so that did -nothing-
    – Rinzwind
    Oct 21 '16 at 17:54
  • /var/www/html/htaccess.txt isn't a valid user either (as the error message states). Oct 21 '16 at 17:55

You need to reset the permissions on /var/www/html back to 0755:

sudo chmod 755 /var/www/html

Explanation: the execute bit in file permissions (x) determines whether the contents of the directory can be enumerated. Turning this bit off (0644) will prevent the web server from being able to see what is in the directory.


The 2 commands ABOVE the one you quoted in the questions messed your system up.

These 2 fix permissions for directories and files:

sudo find /var/www/html -type d -exec chmod 755 {} \;    
sudo find /var/www/html -type f -exec chmod 644 {} \;


sudo chmod 644 /var/www/html

removed execute permissions for your directories.

  • Thaks!!!!! It helps me! :))
    – Igor_77
    Oct 22 '16 at 14:53
  • But why it works so, that that command change rights but not the owner?
    – Igor_77
    Oct 22 '16 at 14:54
  • these 2 only change permissions to the files; not the owner; not the group.
    – Rinzwind
    Oct 22 '16 at 18:52
  • I got it! I thought the problem was in sudo chown, but it was in sudo chmod 644 for folder, but not the file, thats why all files in Html disappeared. I made mistake - should be 755 for folders and 644 for files!
    – Igor_77
    Oct 23 '16 at 11:26

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