Switch user to www-data on AWS EC2 Ubuntu
- January 13, 2016
I found it almost impossible to neatly
su or switch user as
www-data on Ubuntu 14.04 on the AWS EC2. I’m not sure if it’s specific to AWS:
This account is currently not available.
www-data is an important user because it’s the user used by Apache as well as nginx, by default.
I’ve tried creating a
www command, which I would use as a prefix, much like you would use
alias www='sudo -u www-data'
The above was added into
~/.bashrc at the end – but this did not really work for me as I would forget to use the prefix. It’s very unnatural to type
www git pull as you can imagine.
I do think if you add a default shell for www-data, you are able to
su to it however, I don’t think that is best for security. Instead, I now use the following:
sudo su -s /bin/bash www-data
There you go, hope you enjoy this 🙂