Installing PostgresSQL with PostGIS in Elementary OS Juno or Ubuntu 18.04

by | December 30, 2018


Installing PostgresSQL and PostGIS in an Ubuntu based system is not hard, but true to the documentation trends common to most Linux systems it is not always clear to figure out for someone like me who has spent the majority of my working life in a Windows environment where documentation is not only clear and concise but also not typically necessary with the ubiquity of graphical installers and configuration tools.

This tutorial will not assume you have ANY experience in Linux and therefore should be useful for people who are trying to make a quick switch away from Windows or Mac to a FOSS ecosystem.

I have chosen Elementary OS 5.0 as my personal flavour of Linux because…well…it looks cool. Yeah, Ubuntu is better documented and supported, but I liked the look of Elementary and it is based on Ubuntu 18.04 which means that MOST of what you find for Ubuntu works on Elementary, but almost everything you do in Elementary will also work in Ubuntu.

Preparing your system to install new packages

.DEB Packages

If like me, you are diving directly into installing new packages to your Elementary OS system there are a few things that will help you right off the bat. Since Ubuntu, and by extension Elementary OS, are based on Debian Linux you can install .deb packages as applications. Unlike with Ubuntu, Elementary OS doesn’t seem to ship with this ability baked in.

The easiest way is to install  which is a graphical .deb package manager. Open your terminal through the applications menu or by hitting the “Super” Button + “T”. “Super” on most computers is the “Windows” Button.

Once in the terminal:

$ sudo apt-get update
$ sudo apt install gdebi

Now you can install and uninstall .deb packages by using gdebi from your file explorer. Simply right click a downloaded .deb pacakge (Google Chrome for example) and open with gdebi. Done.

Adding new repositories

A repository is a hosted online catalog of precompiled binary installers for Linux software. Elementary OS ships with a number of preconfigured repositories that allow for the installation of common basic software packages like gdebi, but for specialized software such as GIS packages you will need to add extra repositories.

UbuntuGIS is the most important repository you will have to deal with when working with installing GIS software.

To add this repository simply go into the terminal window again and enter:

$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:ubuntugis/ppa

This will install the stable repository for UbuntuGIS which may not contian the most up-to-date packages, but does contain the most stable ones.

**NOTE** If you want to install QGIS 3.4 instead of QGIS 2.18 at a later date I recommend you use:

$ sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable

Instead of the stable version above. This is not strictly necessary but I have found it to work better for me.

Installing PostgreSQL with PostGIS

Now on to the main event. With the proper repository in place it is remarkably easy to install PostgreSQL and PostGIS. Again, back to the terminal window and it is two simple commands:

$ sudo apt-get update
$ sudo apt-get install postgis

This will install PostgreSQL with the PostGIS extensions.

To test to make sure it is installed try switching to the Postgres account on your machine now.

$ sudo -i -u postgres

This should change your username to something along the lines of:

To get back to the normal terminal prompt just type

$ exit


Next Post (Configuring PostGIS and Connecting with QGIS 3)

One thought on “Installing PostgresSQL with PostGIS in Elementary OS Juno or Ubuntu 18.04

  1. Pingback: Getting started with a PostGIS database in QGIS 3 and Linux – T.J. Scientific

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.