How to find out what version of Linux you’re running

The kernel is usually dectected with the uname command.

~# uname -or

Example output:
3.13.0-32-generic GNU/Linux

There really isn’t a cross-distribution way to determine what distribution and version you’re on. There are attempts to make this consistent, but it ultimately varies, unfortunately. LSB tools provides this information, but ironically isn’t always installed by default everywhere.

Example on an Ubuntu 14.04 system with the lsb-release package installed:

~# lsb_release -irc

Example output:
Distributor ID: Ubuntu
Release: 14.04
Codename: trusty

The closest widely-available method is checking “/etc/something-release” files. (ie Red Hat and CentOS).

For example, Ubuntu has /etc/lsb-release:

~$ cat /etc/lsb-release

Example output:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION=”Ubuntu 14.04.2 LTS”

Debian has /etc/debian_version:

~# cat /etc/debian_version

Example output:
5.0.2

Fedora, Red Hat and CentOS have:

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

Red Hat/CentOS: ~# cat /etc/redhat-release
CentOS release 5.3 (Final)

Gentoo:
~# cat /etc/gentoo-release
Gentoo Base System release 1.12.11.1

SUSE:
~# cat /etc/SuSE-release

Slackware:
~# cat /etc/slackware-release

Mandriva:
~# cat /etc/mandriva-release

But for most popular distributions it will be:

~# cat /etc/*{release,version}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s