how to find the version of your linux operating system from command line

Linux and Unix operating systems comes in a wide range of flavors often bundled as different distributions by different vendors. Every one of these distributions also comes with an often pre-defined version of the Linux kernel. Mostly it is a latest version of the kernel, but you would want to check the kernel version to see how up to date it is.

When you need to know the exact name and version of your operating system, as well as the kernel, there are several different ways to do it. There are some common reasons why you might want to check your OS version, it might be it to install the correct version of a software, find if a hardware is compatible or be it to upgrade your OS itself.

As I mentionedthere are several ways to find your operating system and Linux kernel versions. As each distribution (or distros) is slightly different some of these commands might work only in certain distros.


uname is the Linux command which prints out the name, OS versions and other details of the machine and kernel running on the machine. It is basically short for Unix Name. This is usually part of the core-utils package and should be available on almost all distros. There are several options available to print out just the kernel details or just the machine information.

To print out just the kernel information, use the -srv option. It prints out all the available kernel information.

bash$ uname -srv
Linux 3.3.0-gentoo #2 SMP PREEMPT Wed Mar 21 02:07:10 CDT 2012

The first part prints out the kernel name, which is Linux in the above example. The second part is the kernel release version, which is 3.3.0-gentoo. The rest of it is a more detailed kernel information like the compilation date and config.

To print out the machine information, use the -mnipo options.

bash$ uname -mnipo
machinename i686 Intel(R) Core(TM)2 Duo CPU E6850 @ 3.00GHz GenuineIntel GNU/Linux

machinename is the name of the machine, while the rest is the processor architecture, processor type, version, speed and operating system information.

You can also use the -a option which prints out all the available information about the kernel and the machine.

/etc/release and OS version files

Some distributions ships with a separate set of files which specify the release and versions of the distro. These files are usually in the /etc folder with either the word release or version in them or two different files specifying both. You can view these files using any text editor or the cat command.

bash$ cat /etc/*-release*
Gentoo Base System release 2.1

Also try,

bash$ cat /etc/*-version*


bash$ cat /etc/issue

These files should exist in most distributions. They are created on installed from the installer package when you first install the system. However, if you have previously updated the kernel manually then the information in these files might be wrong.


lsb_release (Linux Standard Base Release) is another command which prints out useful information about the distribution. The command has several options to print out specific information, but the -a or the –all option prints out all the information.

bash$ lsb_release -a
LSB Version: n/a
Distributor ID: Gentoo
Description: Gentoo Base System release 2.1
Release: 2.1
Codename: n/a


Another option you have is to check the proc version. You can do so by using the cat command to print out the contents of the /proc/version file.

bash$ cat /proc/version
Linux version 3.3.0-gentoo (root@machinename) (gcc version 4.5.3 (Gentoo 4.5.3-r2 p1.1, pie-0.4.7) ) #2 SMP PREEMPT Wed Mar 21 02:07:10 CDT 2012

This prints out a complete and detailed list of information about your kernel, processor, machine and operating system.

I usually rely on either the uname or the /proc/version file to get the reliable version information for the OS as well as the kernel. You can use the other methods if either of these two options does not work.