postgres command line connect to database code example
Example 1: use database postgres command
\c databasename;
Example 2: postgresql connect to database command line
user@user-pc:~$ sudo -i -u postgres
postgres@user-pc:~$ psql
psql (9.3.5, server 9.3.6)
Type "help" for help.