Linux and Unix operating systems comes in a wide range of flavors often bundled as different distributions by different vendors. Every one of these distribution also comes with an often pre-defined and latest version of the Linux kernel. Sometimes you need to know the exact name and version of your operating system, machine as well as the kernel, be it to install the correct version of a software, find if a hardware is compatible or be it to upgrade your OS itself. There are several ways to check your operating system and linux kernel versions. As each distribution (or distros) are slightly different some of the commands might work in some distros while some maynot.
uname
is the linux command which prints out the name, 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
Output:
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
Output:
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.
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*
Output:
Gentoo Base System release 2.1
DISTRIB_ID="Gentoo"
Also try,
bash$ cat /etc/*-version*
and
bash$ cat /etc/issue
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
Output:
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
Output:
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.