Tuesday, 4 August 2015

How to get Linux distribution name and version in the command line

(1) Using lsb_release

root@kali:/# lsb_release -a

No LSB modules are available.
Distributor ID: Kali
Description: Kali GNU/Linux 1.1.0
Release: 1.1.0
Codename: moto

(2) Print the content of the *release files in /etc:

root@kali:/# cat /etc/*-release

DISTRIB_ID=Kali
DISTRIB_RELEASE=1.1.0
DISTRIB_CODENAME=moto
DISTRIB_DESCRIPTION="Kali GNU/Linux 1.1.0"
PRETTY_NAME="Kali GNU/Linux 1.1.0 (moto)"
NAME="Kali GNU/Linux"
ID=kali
VERSION="1.1.0 (moto)"
VERSION_ID="1.1.0"
ID_LIKE=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.kali.org/"
SUPPORT_URL="http://forums.kali.org/"
BUG_REPORT_URL="http://bugs.kali.org/"

This is the same as printing each *release file on its own:

root@kali:/etc# pwd

/etc

root@kali:/etc# ls *release

lsb-release os-release

root@kali:/etc# cat lsb-release

DISTRIB_ID=Kali
DISTRIB_RELEASE=1.1.0
DISTRIB_CODENAME=moto
DISTRIB_DESCRIPTION="Kali GNU/Linux 1.1.0"

root@kali:/etc# cat os-release

PRETTY_NAME="Kali GNU/Linux 1.1.0 (moto)"
NAME="Kali GNU/Linux"
ID=kali
VERSION="1.1.0 (moto)"
VERSION_ID="1.1.0"
ID_LIKE=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.kali.org/"
SUPPORT_URL="http://forums.kali.org/"
BUG_REPORT_URL="http://bugs.kali.org/"

(3) Use uname command:

root@kali:/etc# uname -a

Linux kali 3.14-kali1-amd64 #1 SMP Debian 3.14.5-1kali1 (2014-06-07) x86_64 GNU/Linux

(4) Print content of the /proc/version file:

root@kali:/# cat /proc/version

Linux version 3.14-kali1-amd64 (debian-kernel@lists.debian.org) (gcc version 4.7.2 (Debian 4.7.2-5) ) #1 SMP Debian 3.14.5-1kali1
Post a Comment