[RESOLVE] Find the name of Ubuntu version with Mint

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post please read how to get help
Locked
percherie
Level 1
Level 1
Posts: 4
Joined: Wed Mar 06, 2013 3:10 pm

[RESOLVE] Find the name of Ubuntu version with Mint

Post by percherie »

Hi,


I use Mint and I want a solution for the name Ubuntu version that matches my version Mint

Nadia For example, I want to get Quantal. It is for use in the command line. Currently the following commands can not function because of the use of $lsb_release -sc

For exemple :

Code: Select all

echo "deb http://download.virtualbox.org/virtualbox/debian `lsb_release -sc` contrib"
OR

Code: Select all

wget --output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list
OR

Code: Select all

echo "deb http://josm.openstreetmap.de/apt `lsb_release -sc` universe #JOSM" | sudo tee -a /etc/apt/sources.list && wget -q http://josm.openstreetmap.de/josm-apt.key -O- | sudo apt-key add - && sudo apt-get update
Last edited by percherie on Wed Mar 06, 2013 5:55 pm, edited 1 time in total.
User avatar
karlchen
Level 22
Level 22
Posts: 16615
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: Find the name of Ubuntu version with Mint

Post by karlchen »

Hello, percherie.

On an absolutely up-to-date Mint13 here, there is a file named /etc/os-release. It has been introduced by some Ubuntu update which turned the underlying Ubuntu into 12.04.2. The content of the file /etc/os-release reads

Code: Select all

NAME="Ubuntu"
VERSION="12.04.2 LTS, Precise Pangolin"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu precise (12.04.2 LTS)"
VERSION_ID="12.04"

Code: Select all

lsb_release -sc
returns the string maya.
So in order to get the string precise which is the codename of the Ubuntu version which Maya has been built upon, I can use the following command:

Code: Select all

grep "PRETTY_NAME" /etc/os-release | awk '{ print $2 }'
It returns the string precise here.
Provided the same file /etc/os-release exists on Nadia as well, the command should return quantal in your case.
I cannot check right now because I am on Mint 13. But I will definitely check next time I boot up Nadia.

HTH,
Karl
Image
The people of Alderaan keep on bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine.
The Prophet's Song
percherie
Level 1
Level 1
Posts: 4
Joined: Wed Mar 06, 2013 3:10 pm

Re: Find the name of Ubuntu version with Mint

Post by percherie »

Thank you

My english it's light but i am all understand ;-)
User avatar
karlchen
Level 22
Level 22
Posts: 16615
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: [RESOLVE] Find the name of Ubuntu version with Mint

Post by karlchen »

Hello, percherie.

As promised, here is the result of the test done on my Mint 14 system:

Code: Select all

$  lsb_release -sc
nadia
$ grep "PRETTY_NAME" /etc/os-release | awk '{ print $2 }'
quantal
$ 
So the command works provided the file /etc/os-release is up-to-date.

Cheers,
Karl
Image
The people of Alderaan keep on bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine.
The Prophet's Song
percherie
Level 1
Level 1
Posts: 4
Joined: Wed Mar 06, 2013 3:10 pm

Re: [RESOLVE] Find the name of Ubuntu version with Mint

Post by percherie »

Thank you karl for your test (and new install of mint)
mirage59
Level 1
Level 1
Posts: 2
Joined: Wed Oct 02, 2013 1:35 pm

Re: [RESOLVE] Find the name of Ubuntu version with Mint

Post by mirage59 »

Hello all,

On Olivia, the previous solution doesn't work for me
(Ubuntu version : 13.04, Raring Ringtail)
so to install JOSM with the openstreetmap.de repository and
stay with a recent version of this amazing tool you can use these commands :

Code: Select all

#Add the key
wget -q http://josm.openstreetmap.de/josm-apt.key -O- | sudo apt-key add -
#Add the repository
echo "deb http://josm.openstreetmap.de/apt `grep "VERSION=" /etc/os-release | tr ',' '\n' | tr '"' ' ' | cut -d' ' -f2 | tail -1 | tr [:upper:] [:lower:]` universe" | sudo tee -a /etc/apt/sources.list
NB : This command isn't elegant but I'm not an awk guru and this have worked fine for me.

Mirage59
mirage59
Level 1
Level 1
Posts: 2
Joined: Wed Oct 02, 2013 1:35 pm

Re: [RESOLVE] Find the name of Ubuntu version with Mint

Post by mirage59 »

Hi all,

I have read a little about awk so this is my prettier solution :

Code: Select all

#Add the key
wget -q http://josm.openstreetmap.de/josm-apt.key -O- | sudo apt-key add -
#Add the repository
echo "deb http://josm.openstreetmap.de/apt `grep "VERSION=" /etc/os-release | awk '{ print $2 }' | tr [:upper:] [:lower:]` universe" | sudo tee -a /etc/apt/sources.list
Feel free to improve it :wink:

Mirage59
percherie
Level 1
Level 1
Posts: 4
Joined: Wed Mar 06, 2013 3:10 pm

Re: [RESOLVE] Find the name of Ubuntu version with Mint

Post by percherie »

mirage59 wrote:Hi all,

I have read a little about awk so this is my prettier solution :

Code: Select all

#Add the key
wget -q http://josm.openstreetmap.de/josm-apt.key -O- | sudo apt-key add -
#Add the repository
echo "deb http://josm.openstreetmap.de/apt `grep "VERSION=" /etc/os-release | awk '{ print $2 }' | tr [:upper:] [:lower:]` universe" | sudo tee -a /etc/apt/sources.list
Feel free to improve it :wink:

Mirage59
Thank you is better, i like it ;-)
Skeptikos
Level 1
Level 1
Posts: 1
Joined: Tue Sep 30, 2014 10:39 pm

Re: [RESOLVE] Find the name of Ubuntu version with Mint

Post by Skeptikos »

In 14.04 / Linux Mint 17, this no longer works for me.

This is my os-release file:

Code: Select all

NAME="Ubuntu"
VERSION="14.04.1 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.1 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
Can't get "trusty" out of the PRETTY_NAME= line like Karl did earlier, and mirage's code returns "LTS,".

This is what I used instead, to get the next-to-last word after "VERSION=":

Code: Select all

grep "VERSION=" /etc/os-release | awk '{print $(NF-1)}' | tr [:upper:] [:lower:]
Hopefully this will work for a few more releases, at least, since it won't be confused by the presence or absence of "LTS" in the long-term support releases.
risimmons
Level 1
Level 1
Posts: 2
Joined: Mon Dec 10, 2012 10:03 am

Re: [RESOLVE] Find the name of Ubuntu version with Mint

Post by risimmons »

I just came across this today. The simple answer is to use lsb_release -ur / -uc to give upstream information. This works on 17.2 - don't know about other releases;

Code: Select all

12:08:15 ~ $ lsb_release -ur
Release:	14.04

Code: Select all

12:12:12 ~ $ lsb_release -uc
Codename:	trusty
SiKing
Level 5
Level 5
Posts: 571
Joined: Mon Sep 29, 2008 10:57 pm
Location: Las Vegas
Contact:

Re: [RESOLVE] Find the name of Ubuntu version with Mint

Post by SiKing »

Was just looking for this solution today. On LM-Sarah 'lsb_release -ur' returns "lsb_release: error: no such option: -u".

However, others mentioned the file `/etc/os-release`, but I think you are all using it wrong. The more elegant solution, IMHO, is:

Code: Select all

$ source /etc/os-release
$ echo $UBUNTU_CODENAME
xenial
No need for `grep` or `awk`, just source the file from your script and the call the appropriate variable.
Locked

Return to “Other topics”