I was using this command chown root:www-data /var/www/example.com -R
,
but there was a message shown that directory not listed.
2 Answers
Once you chown it to owner root and group www-data, in order to access that folder you either have to be the root user, or in the www-data group.
You can add yourself to the www-data group by doing this.
usermod -a -G www-data [your username]
Or you can use sudo to perform any tasks as root.
sudo ls -l /var/www/example.com
Or, if you of course not let root own it at all, which there shouldn't be a reason to.
chown [your username]:www-data /var/www/example.com
The right sintax:
sudo chown -R root:www-data /var/www/example.com
Parameter -R
have to be first.