serverB:~$ sudo -i -u postgres
postgres@serverB:~$ ALTER SYSTEM SET listen_addresses TO '*';
ALTER: command not found
I would like to change some settings in PostgreSQL 15, but I am not sure how to use the ALTER SYSTEM command. I am apparently using the wrong program.
And
sudo su postgres
postgres@serverB:/home/ubuntu$ psql -c "ALTER SYSTEM SET listen_addresses TO '*'"
> could not change directory to "/home/ubuntu": Permission denied
alter systemcan be executed on SQL connection only but the original author of the question tried to execute SQL command onbashcommand line. The solution is simple (just runpsqlfirst) but the more important lesson to learn is that you have to understand which program is active (e.g.bashvspsql) before entering any commands as superuser.