
It is common to run some commands via the postgres
account as it is the de facto PostgreSQL super user. This means that if you’re running these commands remotely, you’ll need to chain sudo:
ssh pg-host sudo -i sudo -u postgres ...
If you’re in charge of the system, you can allow direct sudo
-ing to the postgres
user, but often that is not the case. This means switching to root
first.
As an aside, you can also integrate crossing a jumphost bo