Every time I installed new extensions or do something that generates files and folders, it's like I lose the group, permissions, or magento generate a bad URL, like the cache and the double slash (...cache//...) I need to execute, a lot of times, one or more of the next commands:
sudo chown user:www-data -R .
sudo chmod 777 var
sudo chmod 777 pub
sudo rm -rf var/cache/*
sudo rm -rf generated/*
...
I would like to know if there is any way to force Magento always use the group www-data, and do not create the double slash into the cache folder