Home » Questions » Computers [ Ask a new question ]

How do I find out what version of Linux I'm running?

How do I find out what version of Linux I'm running?

Is there a way to determine what version (distribution & kernel version, I suppose) of Linux is running (from the command-line), that works on any Linux system?

Asked by: Guest | Views: 61
Total answers/comments: 5
Guest [Entry]

"The kernel is universally detected with uname:

$ uname -or
2.6.18-128.el5 GNU/Linux

There really isn't a cross-distribution way to determine what distribution and version you're on. There have been attempts to make this consistent, but ultimately it varies, unfortunately. LSB tools provide this information, but ironically aren't installed by default everywhere. Example on an Ubuntu 9.04 system with the lsb-release package installed:

$ lsb_release -irc
Distributor ID: Ubuntu
Release: 9.04
Codename: jaunty

Otherwise, the closest widely-available method is checking /etc/something-release files. These exist on most of the common platforms, and on their derivatives (i.e., Red Hat and CentOS).

Here are some examples.

Ubuntu has /etc/lsb-release:

$ cat /etc/lsb-release

But Debian has /etc/debian_version:

$ cat /etc/debian_version

Fedora, Red Hat and CentOS have:

Fedora: $ cat /etc/fedora-release
Fedora release 10 (Cambridge)

Red Hat/older CentOS: $ cat /etc/redhat-release
CentOS release 5.3 (Final)

newer CentOS: $ cat /etc/centos-release
CentOS Linux release 7.1.1503 (Core)


$ cat /etc/gentoo-release
Gentoo Base System release

I don't have a SUSE system available at the moment, but I believe it is /etc/SuSE-release.

Slackware has /etc/slackware-release and/or /etc/slackware-version.

Mandriva has /etc/mandriva-release.

For most of the popular distributions then,

$ cat /etc/*{release,version}

will most often work. Stripped down and barebones ""server"" installations might not have the 'release' package for the distribution installed.

Additionally, two 3rd party programs you can use to automatically get this information are Ohai and Facter.

Note that many distributions have this kind of information in /etc/issue or /etc/motd, but some security policies and best practices indicate that these files should contain access notification banners.

How to find out version of software package installed on the node?,
Guest [Entry]

Kernel: uname -a
Guest [Entry]

cat /proc/version found me Red Hat on a shared VPS.
cat /proc/version found me Red Hat on a shared VPS.
Guest [Entry]

"Kernel: uname -r

Distro: lsb_release -a

These will run on most Linux systems"
Guest [Entry]

lsb_release -a && uname -r"