I was using this command
chown root:www-data /var/www/example.com -R,
but there was a message shown that directory not listed.
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.
Or you can use sudo to perform any tasks as root.
Or, if you of course not let root own it at all, which there shouldn't be a reason to.
The right sintax: