Why does Drush require sudo? I’m running Ubuntu 14.04.5 with Drush v 8.1.8 and I can’t seem to execute Drush without using sudo. For example if I try to execute ‘drush cc all’ without sudo, I get:

‘Directory /home/myuser/.drush/cache/default exists, but is not writable. Please check directory permissions. ‘
‘Directory /home/myuser/.drush/cache/complete exists, but is not writable. Please check directory permissions.   ’

If I then manually modify the permissions on .drush and everything under it to 777, the next Drush command will work but the one after that will fail with the same error. I also tried ‘chown -R myuser:myuser ~/.drush’.  Same result.

I thought perhaps I installed Drush incorrectly, so I tried removing and then re-installing it three different ways:


Using this approach: https://www.drupal.org/node/1248790 (sudu apt-get install drush).
This way: http://docs.drush.org/en/master/install/ (executing php to load Drush from a remote file)
Finally by installing Drush using method (2) and then moving Drush into my home/bin folder and chown -R to me.


All of them have the same result — drush doesn’t work without sudo. There’s no reason I can think of why this should be. What’s even weirder is if I chown of .drush (and everything under it) to me, then execute drush without sudo, it will change ownership of directories under .drush/cache to root. I don’t even know how that’s possible since I’m not root!

Please let me know how I can get Drush to work without root privileges.
Thanks.
I'd suggest you follow the official install instructions here after removing your current install - http://docs.drush.org/en/master/install/

When you have it installed then navigate to your home folder:

cd ~/
ls -lash


At this point your .drush folder should have your user as owner (not root)

If it doesn't then run

sudo chown myusergoeshere:myusergoeshere .drush -R


You can run ls -lash again and confirm the right user and group.

You should now be able to run drush without using sudo.



The reason you get that error is because when you installed it the system created the folder using the root user in your home directory so as your user you don't have permission to modify the folder.