open postgresql in terminal ubuntu code example Example 1: start postgresql ubuntu sudo service postgresql start Example 2: ubuntu connect to postgres sudo su - postgres