When I log into postgres under my personal shell account, my .psqlrc file runs a series of meta commands to set up what is for me an optimum working environment. I'd like to set that same environment as the default when I or anyone else logs in as user postgres. I've been searching for a long time for a way to do this. The closest I have come is the following.
- Find the system-wide configuration directory:
pg_config --sysconfdir
This returns /etc/postgresql-common
. After cd'ing into this directory, can find no psqlrc file. So I make one, adding a test line to turn off that annoying pager behavior:
\pset pager off
...and save. So far, so good. Permissions and ownership (root) all look good, same as the other files in this directory. Then I try logging into postgres as postgres:
sudo -u postgres psql postgres
and...nothing. No change.
Next, because we have more than one db cluster (currently running pg 10, but also have an inactive pre-upgrade pg 9.3 cluster that I'm not quite ready to get rid of) I get back into /etc/postgresql-common and rename psqlrc to psqlrc-10, following instructions here: http://manpages.ubuntu.com/manpages/bionic/man1/psql.1.html
.
Finally, I log back into postgres as postgres and...no change. I've also tried logging out entirely and logging back in. Still no change.
This is the latest of many attempts. I'm sparing you the earlier versions. Is it possible that /etc/postgresql-common/psqlrc only affects interactive terminal behavior for non-postgres users? If so, how do I make changes for user postgres? If not, where on earth is that darn system-wide psqlrc file?
psql
as user postgres?PGSYSCONFDIR
set? 2) Check if thepsql
you are invoking is a shell script wrapper that does some setup that foils your attempts. 3) Is thepsql
executable that is used from the same installation as thepg_config
you called to determine the configuration directory?