As you know, very often you can be faced with one or another issue connected with incorrect or broken permissions on your site’s Apache server, so either you are not allowed to modify files and write to directories (as SFTP User), or your CMS or other application would refuse to work properly if you do upload files to the server with incorrect permissions.
If it happens that you have SSH access to the server, the following commands will very often fix the issues. Tested multiple times on Ubuntu/Debian systems.
- Add your user to the www-data group which is the default group that Apache runs on Ubuntu:
sudo usermod -a -G www-data YourUSernameHere
- Change the owner of the /var/www directory to be the www-data user + group:
sudo chown -R www-data:www-data /var/www
- Set the correct permissions:
sudo chmod -R g+rwX /var/www
For more info about the Linux permissions you can check this or this site.