How to get OS info in Linux

Many times you may need to now the operating system information. We will discuss some useful commands. We will focus on commands that work on RedHat/CentOS installations, as these are the most used OSs in the web hosting industry.

1.1. For kernel version information, use uname -a

root@web [~]# uname -a
Linux web.plothost.com 2.6.32-042stab134.8 #1 SMP Fri Dec 7 17:16:09 MSK 2018 x86_64 x86_64 x86_64 GNU/Linux
root@web [~]#

1.2. Another command for kernel information is cat /proc/version

root@web [~]# cat /proc/version
Linux version 2.6.32-042stab134.8 (root@kbuild-rh6-x64.eng.sw.ru) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) ) #1 SMP Fri Dec 7 17:16:09 MSK 2018
root@web [~]# ^C

2.1. To get the operating system version on RedHat distributions (RedHat, CentOS etc), use cat /etc/redhat-release

root@web [~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
root@web [~]#

2.2. For other Linux distributions, use cat /etc/*-release

root@web [~]# cat /etc/*-release
CentOS Linux release 7.7.1908 (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.7.1908 (Core)
CentOS Linux release 7.7.1908 (Core)
root@web [~]#

2.3. Another command here is lsb_release -a. This command will list some LSB (Linux Standard Base) information.

root@web [~]# lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.7.1908 (Core)
Release:        7.7.1908
Codename:       Core
root@web [~]#

3. Info about the hostname, virtualization type, architecture, kernel can be shown by using hostnamectl command.

root@web [~]# hostnamectl
   Static hostname: web.plothost.com
         Icon name: computer-container
           Chassis: container
        Machine ID: 8ae4190274f046cea9ff6079c62ba82f
           Boot ID: 1ab0cef548a8424298b26d7247d3440a
    Virtualization: openvz
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 2.6.32-042stab134.8
      Architecture: x86-64
root@web [~]# 

Leave a Reply