Fixing permissions and ownership in Drupal 7

If you work with Drupal a lot and you’re on linux, you will come across times when you have to migrate/copy/restore your site from one location to another – sometimes on the same server, other times on a new server or your local machine. And when you move/copy/migrate your Drupal instance, you will notice that file ownership and permissions will go out of sync. Whenever this happens, I always go to the Drupal’s Securing file permissions and ownership and run a series of commands to correct everything.

fix-permissions-in-drupal

To make it easier to run the commands, I wrote a simple bash script that will execute all the commands to fix the permissions and ownership altogether. This is so that I can come back to this post as a reference instead of going to the Drupal page and run command one by one. And I thought there may be some people out there who can use this script to save some time like me.

Just make it executable and run it like following:

Here you go!

Leave a Reply

Your email address will not be published. Required fields are marked *