postgres@ubuntu:~$ psql
psql (9.6.5, server 9.3.19)
Type "help" for help.
postgres=# \conninfo
You are connected to database "postgres" as user "postgres" via socket in "/var/run/postgresql" at port "5432".
postgres=# \q
postgres@ubuntu:~$ exit
logout
administrator@ubuntu:~$
administrator@ubuntu:~$ sudo -u postgres psql postgres
psql (9.6.5, server 9.3.19)
Type "help" for help.
postgres=# \password
Enter new password:
Enter it again:
postgres=# \conninfo
You are connected to database "postgres" as user "postgres" via socket in "/var/run/postgresql" at port "5432".
postgres=# \q
administrator@ubuntu:~$
administrator@ubuntu:~$ psql -h localhost -p 5432 -U postgres postgres
Password for user postgres:
psql (9.6.5, server 9.3.19)
SSL connection (protocol: TLSv1.2, cipher: DHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
postgres=# \conninfo
You are connected to database "postgres" as user "postgres" on host "localhost" at port "5432".
SSL connection (protocol: TLSv1.2, cipher: DHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
postgres=# \q
administrator@ubuntu:~$