Find Out My Linux Distribution Name and Version

~ 2 min read

How many times as a dev have you been pointed at an empty or inherited box and told to build on it not knowing what exact distro its running, and if your like me you then have to google for the commands as well? I hope this helps.

1: /etc/*-release file

To find out what version of Linux (distro) you are running, enter the following command at the shell prompt:

$ cat /etc/*-release

Sample output from my RHEL v5.x server:

Red Hat Enterprise Linux Server release 5 (Tikanga)

Sample outputs from my Ubuntu Linux v7.10 server:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=7.10
DISTRIB_CODENAME=gutsy
DISTRIB_DESCRIPTION="Ubuntu 7.10"

2: lsb_release find out Linux distribution name/version

The lsb_release command displays certain LSB (Linux Standard Base) and distribution-specific information. Type the following command:

$ lsb_release -a

Sample outputs:

No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 6.0.1 (squeeze)
Release:	6.0.1
Codename:	squeeze

Whats my linux kernel version?

Type the following command:

$ uname -a
# OR
$ uname -mrs

Sample outputs:

Linux 2.6.32-504.16.2.el6.x86_64 x86_64

Where,

  • 2.6.32-504.16.2.el6.x86_64 - Kernel version number
  • Linux - Kernel name
  • x86_64 - Machine hardware name (64 bit)

Gotta love /proc/version

Type the following command to see kernel version and gcc version used to build the same:

$ cat /proc/version

Sample outputs:

Linux version 2.6.32-504.16.2.el6.x86_64 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) ) #1 SMP Wed Apr 22 06:48:29 UTC 2015

all posts →