Ubuntu: Install PostgreSQL and pgAdmin

Installing PostgreSQL on Ubuntu was always a problem for me when I started using PostgreSQL. The problem was in setting up the root user credentials. I have tried lot of commands with no success. After so many tries I found which is correct command to use. I'm documenting the steps here which will help some newbies trying to install PostgreSQL on Ubuntu.