What's the difference between sudo su - postgres and sudo -u postgres?
Posted
by
Craig Ringer
on Server Fault
See other posts from Server Fault
or by Craig Ringer
Published on 2014-06-02T08:07:28Z
Indexed on
2014/06/02
9:30 UTC
Read the original article
Hit count: 294
PostgreSQL users peer authentication on unix sockets by default, where the unix user must be the same as the PostgreSQL user. So people frequently use su
or sudo
to become the postgres
superuser.
I often see people using constructs like:
sudo su - postgres
rather than
sudo -u postgres -i
and I'm wondering why. Similarly, I've seen:
sudo su - postgres -c psql
instead of
sudo -u postgres psql
Without the leading sudo
the su
versions would make some sense if you were on an old platform without sudo
. But why on a less than prehisoric UNIX or Linux would you use sudo su
?
© Server Fault or respective owner