29 Feb 2008 softkid   » (Journeyer)

What version of Linux is my machine running ?

Today I needed to report a bug on a piece of software that ran on a linux system. The bug report form asked for a version of the system I was running. On traditional unix system (By these I mean Solaris, HP-UX, Aix), I would run uname -a and the third or fourth argument would be the os name and version. Done I could report my OS version number. I could always run a few other command that would be specific to learn a bit more about the version - but uname -a would give me the information straight away.
so on my Ubuntu system it gave me :

ludo@toto:~$ uname -a
Linux toto 2.6.22-14-server #1 SMP Tue Dec 18 05:52:24 UTC 2007 x86_64 GNU/Linux

Which did not help a lot. After poking a bit I found the following, each distribution as a file in /etc which gives this information :

etc/redhat-release
etc/SuSE-release
etc/gentoo-release
etc/yellowdog-release
etc/mandrake-release
etc/whitebox-release
etc/debian_version

As Ubuntu is a debian derivative it uses the etc/debian_version file - but this might not be enough, the real nice command to run is lsb_release. On OpenSuse this gives :

toto0:~ # lsb_release -a
LSB Version: core-2.0-noarch:core-3.0-noarch:core-2.0-x86_64:core-3.0-x86_64:desktop-3.1-amd64:desktop-3.1-noarch:graphics-2.0-amd64:graphics-2.0-noarch:graphics-3.1-amd64:graphics-3.1-noarch
Distributor ID: SUSE LINUX
Description: openSUSE 10.3 (X86-64)
Release: 10.3
Codename: n/a

and on Ubuntu it gives :

ludo@toto:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 7.10
Release: 7.10
Codename: gutsy

As one can see the lsb_release command is the command to figure out which version of linux and which distribution your system is running.
To be complete on AIX the command that gives you more information is oslevel. On Mac OS X it's sw_vers. I currently can't recall what it is for sun, nor for HP-UX.

Syndicated 2008-02-29 10:19:54 from Ludovic's weblog

Latest blog entries     Older blog entries

New Advogato Features

FOAF updates: Trust rankings are now exported, making the data available to other users and websites. An external FOAF URI has been added, allowing users to link to an additional FOAF file.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!