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
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 :
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)
and on Ubuntu it gives :
ludo@toto:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 7.10
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.