Barry Hughes WordPress Developer

You are browsing posts tagged “bash”.

Determining the Ubuntu codename in Linux Mint

5 March 2018

Often, when setting up repositories on Ubuntu and related distros, you will need to know the release codename. In general, you can grab this using:

lsb_release -cs

This is great, except the codename you receive if you use this under Linux Mint (let’s say “sylvia”) may not match the codename you would receive if you used the same command under a stock Ubuntu install (let’s say “xenial”) and oftentimes it’s the upstream codename (“xenial” in my example) that you will need.

The information is readily available with some search engine-foo, but it can also be found locally within /etc/upstream-release/lsb-release. I wanted a handy one liner for the future, so I added the following line to my .bash_aliases files:

alias upstream-lsb="grep DISTRIB_CODENAME /etc/upstream-release/lsb-release | grep -o --colour=never \"[a-z-]*$\""

With that in place (don’t forget to reload it, ie source ~/.bash_aliases or equivalent!) things are a piece of cake. Example of usage:

$ upstream-lsb
xenial