The following line is meant for Ubuntu version 16.04 (xenial-xerus). If you are on Ubuntu version 18, replace the word "xenial" with "bionic"
$ sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
This is for Ubuntu 18:
$ sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
Once you have one of the above commands -- as in not both commands, you will continue on running the following commands: