How to install PostgreSQL 9.5 on Ubuntu/Debian/Linux Mint

NOTE: Here is an updated version to install PostgreSQL 9.6 on Ubuntu Xenial

Create a file at /etc/apt/sources.d/postgresql.list with the following command:

vim /etc/apt/sources.list.d/postgresql.list

Add the following line according to your distribution (utopic, trusty, jessie, wheezy and etc):

deb trusty-pgdg main 9.5

Save it and Close it! Now you just have to do:

wget --quiet -O - | sudo apt-key add -
apt-get update
apt-get install postgresql-9.5

Enjoy it! 😀