This is a brief howto for finding out which version of Linux you are running. I say “brief” because this is certainly not comprehensive. There are a few ways to skin this cat, depending on which Linux distribution you are running. I will only cover Debian and Ubuntu. Similar techniques may work on other distros (especially Debian derivatives) but your mileage may vary.
But first, why should you even care which version you are running? There are many reasons why you should care, but perhaps the best reason is that it comes in handy when you are troubleshooting errors. For example, if you are a Linux newbie and you post an error message on a forum asking for help troubleshooting it, you can bet that the first response will include the question: “Which version of Linux are you running?”. Knowing the version can sometimes also come in handy when you are installing new packages when the package is dependent on a certain version of Linux.
Note that the question “Which version of Linux are you running?” is actually sort of ambiguous. Sometimes you want to know the version of the Linux kernel and other times you want to know the version of the Linux distribution.
To get the version of the Linux kernel, you use the uname command, which I believe should be available on all distributions. For example:
me@mycomputer:~$ uname -r 2.6.18-5-686
In the above example, we see that the kernel version is 2.6.18-5-686. You can also use the -a option to get even more information:
me@mycomputer:~$ uname -a Linux mycomputer 2.6.18-5-686 #1 SMP Fri Jun 1 00:47:00 UTC 2007 i686 GNU/Linux
To find out the version of the Linux distribution, there are a few ways, depending on the distro. In Ubuntu, version information is stored in the files /etc/issue and /etc/lsb-release. You can simply cat these files to see the information. Here is what I found on an Ubuntu 7.10 box:
me@mycomputer:~$ cat /etc/issue Ubuntu 7.10 \n \l
me@mycomputer:~$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=7.10 DISTRIB_CODENAME=gutsy DISTRIB_DESCRIPTION="Ubuntu 7.10"
On Debian and Debian derivatives (e.g. Ubuntu), version information is stored in the file /etc/debian_version. Here is what the file contained on a Debian 4.0 box:
me@mycomputer:~$ cat /etc/debian_version 4.0
And here is what the file contained on an Ubuntu 7.10 box:
me@mycomputer:~$ cat /etc/debian_version lenny/sid
I did some googling and found that some other distros follow this /etc/*version convention. For example, apparently Red Hat stores version infomation in /etc/redhat-version. I don’t have a Red Hat system lying around (I haven’t had one since they split into Red Hat and Fedora) so I couldn’t try it. Therefore, I’ll just take it as a matter of faith that this is true. On other distros, chances are that you’ll have a *version file in your etc directory.
Finally, another way you can find out the distro version is with the lsb_release command. Here is the output from an Ubuntu 7.10 box:
me@mycomputer:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 7.10 Release: 7.10 Codename: gutsy
And here is the output from a Debian 4.0 box:
me@mycomputer:~$ lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 4.0r1 (etch) Release: 4.0r1 Codename: etch
I’m not sure if that command is available on all distros or just Debian and its derivatives. For other distros, I leave that as an exercise to the reader. If the command is not installed on your Debian or Debian derivative box, you can install it with: apt-get install lsb-release. Note that you might need to su or sudo before installing it. Note also that the package name has a hyphen (”-”) whereas the command has an underscore (”_”). That difference got me the first time.
If this tip helped you, please leave me a comment or send me an email!







It’ s was very usefull. There can be implemented some explenation, and one of them is how to recognize bit version of instaltation (usally in the name of kernel vesrion).
Best regards,
Petar
It’s so greats! Thanks.
very useful.
Tried it and it works fine with SuSE too.
Tachyon
# 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.2 (X86-64)
Release: 10.2
Codename: n/a
I used this method on debian-etch 2.6.18-6 and of course it worked fine. One interesting point is why I wanted to know. I had a funny situation where I had done an update thru synaptic with no problems. The update included the next version of the kernel. So when I rebooted to let the update take effect, it didnt reboot, but instead gave me an error message saying the kernel image was corrupted(the check sum didnt match). Then I rebooted to the previous version -5,which was still ok. After that I wanted to record all the error messages so I rebooted to -6 expecting it to fail as before. But no, it booted with no problems which left me mystified. So, finally, here’s the point. I wanted to know for sure what version I was running and it was -6. Now my mind is at ease. I am sure I am back to the correct version. Thanks very much. It is very useful to know where you are and what’s what.
Chuck