WordPress Update failed: The update cannot be installed because we will be unable to copy some files

While updating a WordPress plugin if you are getting the folloiwng issue:

Update failed: The update cannot be installed because we will be unable to copy some files. 
This is usually due to inconsistent file permissions.

The solution is to run the following commands:

sudo groupadd www-my-grp

sudo chgrp -R www-my-grp /var/www

sudo chmod 2775 /var/www

sudo find /var/www -type f -exec chmod 2775 {} +

sudo find /var/www -type d -exec chmod 2775 {} \;

sudo chown -R www-data:www-my-grp /var/www/my.wordpresssite.com

sudo chmod -R 775 /var/www/my.wordpresssite.com

Running the above command will give the following permissions to yowur wordpress site:

drwxrwsr-x 11 www-data www-my-grp 4096 Jun 23 03:35 my.wordpresssite.com

Updating the wordpress plugin will work now and will give the Updated! status to you.