Logging into psql as postgres user:
sudo -u postgres psql
Switching databases:
\c [DB NAME]
Executing an example query:
SELECT * from user;
Note that SELECT has to be capitalized, otherwise it will result in a syntac error. Also don’t forget the ; at the end of the query.
Exiting psql:
\q