[bbarsch@Users2 ~]$ psql -V
psql (PostgreSQL) 11.3
[bbarsch@Users2 ~]$ locate bin/psql
locate: can not open `/var/lib/mlocate/mlocate.db': Permission denied
[bbarsch@Users2 ~]$ sudo su -
Last login: Mon Jun 7 10:17:37 SAST 2021 on pts/1
[root@Users2 ~]# locate bin/psql
/usr/bin/psql
/usr/pgsql-11/bin/psql
/var/lib/docker/overlay2/2b31d1b719562538725c5fe4167a6642415d38973de481e5a75df2382249705b/diff/usr/local/bin/psql
/var/lib/docker/overlay2/940e907dbff569070f57920a5fc2593c4d7827885bbc5c1426ce4a40addd6d02/diff/usr/bin/psql
[root@Users2 ~]# psql
psql: FATAL: role "root" does not exist
[root@Users2 ~]# su - chpc
Last login: Mon Jun 7 10:17:39 SAST 2021 on pts/1
[chpc@Users2 ~]$ psql
psql: FATAL: database "chpc" does not exist
[chpc@Users2 ~]$ logout
[root@Users2 ~]# sudo su - postgres
Last login: Fri Jun 7 09:58:20 SAST 2019 on pts/1
-bash-4.2$ psql
psql (11.3)
Type "help" for help.
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access priv
ileges
---------------+----------+----------+-------------+-------------+--------------
---------
chpcuser | chpc | UTF8 | en_ZA.UTF-8 | en_ZA.UTF-8 |
new | postgres | UTF8 | en_ZA.UTF-8 | en_ZA.UTF-8 | =Tc/postgres
+
| | | | | postgres=CTc/
postgres+
| | | | | chpc=CTc/post
gres
postgres | postgres | UTF8 | en_ZA.UTF-8 | en_ZA.UTF-8 |
template0 | postgres | UTF8 | en_ZA.UTF-8 | en_ZA.UTF-8 | =c/postgres
+
| | | | | postgres=CTc/
postgres
template1 | postgres | UTF8 | en_ZA.UTF-8 | en_ZA.UTF-8 | =c/postgres
+
| | | | | postgres=CTc/
postgres
test_chpcuser | chpc | UTF8 | en_ZA.UTF-8 | en_ZA.UTF-8 |
testme | chpc | UTF8 | en_ZA.UTF-8 | en_ZA.UTF-8 |
(7 rows)
postgres=#
postgres=#
postgres=# q
postgres-# :q
postgres-# exit
Use \q to quit.
postgres-# \q
-bash-4.2$ q
-bash: q: command not found
-bash-4.2$ exit
logout
[root@Users2 ~]#
https://chartio.com/resources/tutorials/how-to-view-which-postgres-version-is-running/#using-sql
Reference: https://phoenixnap.com/kb/how-to-install-postgresql-on-ubuntu