Recently updated from Postgresql 9.1 to 9.3.
Everything works fine, but I noticed now when I type in:
sudo -u postgres psql
I am getting hit with a permission denied error for changing dir to root.
"Could not change directory to /home/root.
However, when I use:
sudo su - postgres
psql
It accesses it fine. How can I fix this?
change directory to someplace that postgres has access to:
cd /tmp
sudo -u postgres psql
Try this:
sudo -i -u postgres psql
This accomplishes (almost) the same thing as your
sudo su - postgres
The -
in the above indicates that you want to use the postgres account's environment. If you remove the -
, it will fail similarly to sudo -u
The -i
indicates that you want to run the postgres account's login shell (hence cd
ing to their home directory).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With