Simple steps for installing Qgis on Ubuntu or WSL

TLDR; Quick recipie for installing newest stable version of QGIS on Ubuntu (plain or WSL ubuntu).

I find the average recipie for installing more up-to-date versions of … anything on linux, basically…. rather difficult  to follow. For me, code words like Bionic does not translate easily into how to to modify the file /etc/apt/sources.list , or what sudo apt  magic I should perform.

So this recipie is helpful only to expert linux users.

Unless you want to install .deb files manually, of course. But you don’t want that – you want to add the repositories so that updates roll in whenever you do sudo apt update && sudo apt -y upgrade.

The best recipie I’ve found so far

This is the easiest breakdown I’ve ever seen of this process:

Thank you, Phil Mike Jones. I learned a lot, and you solved a problem for me.

Translated into do this – then that steps

For my own memory, and possibly benefit of other, provide the the actuall commands needed (valid as of 3d of April, 2020). Updating with fresh, relevant details should be straightforward.

Add repository

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

Add key to that repository

wget -O - | gpg --import
gpg --fingerprint 51F523511C7028C3
gpg --export --armor 51F523511C7028C3 | sudo apt-key add -

This key should expire around August 2020 or so, unless I’ve misread some of the techspeak from these commands.

Edit the apt/sources file

The file /etc/apt/sources.list should be edited with your favorite editor, run as sudo. Add these following lines.

# Qgis ubuntugis dependencies
deb bionic main
deb-src bionic main

Final installation

sudo apt update
sudo apt upgrade
sudo apt install qgis python-qgis

The final qgis command should now start QGIS just fine.

Bonus: This works in WSL, but you need Xming (or similar)

WSL – Windows subsystem for linux – is a real life saver. Such as when my windows QGIS installation is beyond repair I can just install and run it in WSL. I run Ubuntu in my WSL.

But you need some tweaking to get graphical programs to work. Easy. Just install Xming or some equivalent and make sure to start it (just find it – click it).

In WSL, type:

export DISPLAY=:0

before starting any graphical commands. To test this, do:

sudo apt install x11-apps