如何查看Linux系统的版本

时间:2019-11-20 08:53:43  来源:igfitidea点击:

Suse,OpenSUSE,Debian,Ubuntu,CentOS,Arch,Fedora,RHEL都是常见的Linux发行名称。
如何查看Linux系统的发行名称?
如何检查Linux系统版本?

使用/etc/os-release文件

执行以下cat命令:

$ cat /etc/os-release

输出示例:

NAME="Ubuntu"
VERSION="17.10 (Artful Aardvark)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 17.10"
VERSION_ID="17.10"
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=artful
UBUNTU_CODENAME=artful

lsb_release命令

lsb_release命令可以查看发行版的信息。
语法为:

$ lsb_release -a

输出示例:

LSB Version:	:core-4.1-amd64:core-4.1-noarch
Distributor ID:	CentOS
Description:	CentOS Linux release 7.4.1708 (Core) 
Release:	7.4.1708
Codename:	Core

hostnamectl命令

查看操作系统名称和Linux内核版本:

$ hostnamectl

输出示例:

   Static hostname: theitroad
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 0e38ae5f500045f4b8c721a3e630c01a
           Boot ID: 29670a3f76ff405699a2965ce249d621
    Virtualization: vmware
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-1127.el7.x86_64
      Architecture: x86-64

uname命令

查看Linux内核版本,运行:

$ uname -r

或者直接查看/proc/version文件

$ cat /proc/version

输出示例:

Linux version 3.10.0-1127.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) ) #1 SMP Tue Mar 31 23:36:51 UTC

/etc/issue文件

$ cat /etc/issue
$ more /etc/issue
$ less /etc/issue