How to fix a WordPress Permissions Update Error

This is the error message I got when trying to update my wordpress:

Unpacking the update...

The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.: wp-admin/includes/update-core.php

Installation Failed

An automated WordPress update has failed to complete

Incosistent permissions.

This means you have several users in your home folder and you have to give each user the permissions of the right website.

Reset the permissions of all files to 664:

find /path/to/site/ -type f -exec chmod 664 {} \;

Reset permissions of directories to 775:

find /path/to/site/ -type d -exec chmod 775 {} \;

Reset the group to the correct group

To find out which group you should reset the group to , you need to know  which groups a user is in. You can use the following command:

 $ groups {username}

Then reset the group to the correct group

chgrp -R groupname /path/to/site/