1 How to view OS version on Linux

  • cat /etc/os-release

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    [root@bogon ~]# cat /etc/os-release     // cent os
    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"
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    root@395c51a2be53:/# cat /etc/os-release    //ubuntu
    NAME="Ubuntu"
    VERSION="20.04.2 LTS (Focal Fossa)"
    ID=ubuntu
    ID_LIKE=debian
    PRETTY_NAME="Ubuntu 20.04.2 LTS"
    VERSION_ID="20.04"
    HOME_URL="https://www.ubuntu.com/"
    SUPPORT_URL="https://help.ubuntu.com/"
    BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
    PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
    VERSION_CODENAME=focal
    UBUNTU_CODENAME=focal
  • hostnamectl

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    [root@bogon ~]# hostnamectl     //cent os 
    Static hostname: localhost.localdomain
    Transient hostname: bogon
    Icon name: computer-vm
    Chassis: vm
    Machine ID: c88ed388db814131ba13845cb03d9fde
    Boot ID: e779409a6a4f4c1a84fb43fe812bcf73
    Virtualization: vmware
    Operating System: CentOS Linux 7 (Core)
    CPE OS Name: cpe:/o:centos:centos:7
    Kernel: Linux 3.10.0-514.el7.x86_64
    Architecture: x86-64

2 How to view kernel version of Linux

  • uname -r # (All Linux version can use this command)

    1
    2
    [root@bogon ~]# uname -r   //cent os
    3.10.0-514.el7.x86_64

Reference Page

How to check os version in Linux command line

写在最后

欢迎大家关注鄙人的公众号【麦田里的守望者zhg】,让我们一起成长,谢谢。
微信公众号