Steps to install PostgreSQL in Linux server
PrerequisitesYou will need to have access to a superuser, or sudo account, so you can install the PostgreSQL database software
Installation
First, update apt-get library
$ sudo apt-get update
Then install PostgreSQL and its development libraries
$ sudo apt-get install postgresql postgresql-contrib libpq-dev
PostgreSQL is now installed
Create PostgreSQL User
To create new user run the below command with your own user name
$ sudo -u postgres createuser -s <pg-username>
If you want to set a password for the database user, enter the PostgreSQL console with this command
$ sudo -u postgres psql
Enter the following command in PostgreSQL prompt to set the password for the user that you created before
postgres=# \password pguser