Learn how to check the Linux kernel version using the command line. Helpful commands to check your kernel versions, releases, codenames, etc.
This post aims at checking your Linux kernel version using commands. We will be discussing different ways to fetch this data from your system. Below is a list of commands which can be used to get Linux kernel version details.
You can use below 7 ways to gather info about your distribution like kernel version in CentOS, RHEL, SUSE, OEL, Ubuntu, Debian Linux. All the below outputs are from my test machine running CentOS 7.
1. By reading version process file.
This gives you running kernel version.
[root@kerneltalks1 ~]# cat /proc/version
Linux version 3.10.0-693.5.2.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ) #1 SMP Fri Oct 20 20:32:50 UTC 2017
3.10.0-693.5.2.el7.x86_64
is your current kernel distribution version.
2. By reading Distro release file in /etc
Almost all distributions of Linux come with a release file in /etc
which contains the kernel version, release details in it. Its a text file hence cat
can be used to read its content.
# cat /etc/enterprise-release OR /etc/oracle-release ---For OEL
Enterprise Linux Enterprise Linux Server release 5.8 (Carthage)
[root@kerneltalks1 ~]# cat /etc/redhat-release ---For RHEL/OEL
CentOS Linux release 7.4.1708 (Core)
OR simple use wildcard so that you can list the release file of any distro. All distro keeps diff filenames so using wildcard will be wise. In some distro, you will see /etc/os-release
or /etc/system-release
files as well. All these files will be covered when using wild cards.
[root@kerneltalks1 ~]# cat /etc/*release
CentOS Linux release 7.4.1708 (Core)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
CentOS Linux release 7.4.1708 (Core)
CentOS Linux release 7.4.1708 (Core)
3. By listing release package
This command works for RPM-based systems like RHEL, SUSE, OEL, CentOS, etc. Search and grep for release which will show you release package. This package name convention includes release number in it.
[root@kerneltalks1 ~]# rpm -qa |grep -i release
centos-release-7-4.1708.el7.centos.x86_64
4. Using uname
command
This command works on all flavors of Linux. You can use it on RHEL, SUSE, OEL, Debian, Ubuntu, etc.
[root@kerneltalks1 ~]# uname -r
3.10.0-693.5.2.el7.x86_64
This value indicates your current kernel version.
5. Using lsb_release
command
lsb_release
command is provided by redhat-lsb
package. You need to install redhat-lsb package in order to use this command on RHEL, CentOS or Fedora systems.
[root@kerneltalks1 ~]# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.4.1708 (Core)
Release: 7.4.1708
Codename: Core
6. Using hostnamectl
command
In newer kernels, hostnamectl
command is introduced. Using this command without any argument will show you all details about your kernel. You can use it to set your hostname as well.
[root@kerneltalks1 ~]# hostnamectl
Static hostname: kerneltalks1
Icon name: computer-vm
Chassis: vm
Machine ID: 49688f1b932a41e790254b993d419ccc
Boot ID: 4777133835544d599a46a53ae4b584e3
Virtualization: xen
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-693.5.2.el7.x86_64
Architecture: x86-64
Share Your Comments & Feedback: