您的位置:首页 > 运维架构 > Linux

查看Linux版本信息命令

2017-08-08 13:37 417 查看
通常使用命令uname在Linux下面察看版本信息

-a或--all:显示全部的信息;
-m或--machine:显示电脑类型;
-n或-nodename:显示在网络上的主机名称;
-r或--release:显示操作系统的发行编号;
-s或--sysname:显示操作系统名称;
-v:显示操作系统的版本;
-p或--processor:输出处理器类型或"unknown";
-i或--hardware-platform:输出硬件平台或"unknown";
-o或--operating-system:输出操作系统名称;
--help:显示帮助;
--version:显示版本信息。

RedHat:

uname -a

Linux localhost.localdomain 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

Centos:

uname -a

Linux localhost.localdomain 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Debian:

uname -a

Linux debian 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u1 (2016-09-03) x86_64 GNU/Linux

-a选项表示察看所有的信息,但是从输出信息可以看出来,uname看到的版本信息,只是内核版本的信息,而不是发行版的版本信息

那如果我们想察看发行版的信息的话

RedHat:

cat /etc/redhat-release

Red Hat Enterprise Linux Server release 5.5 (Tikanga)

Centos:

cat /etc/centos-release

CentOS Linux release 7.2.1511 (Core) 

Debian:

cat /etc/debian_version

8.6

那有没有一个更加通用的方法呢?那就是/etc/issue文件,issue文件是登录前的信息和标识文件,里面存放了发行版的版本信息

RedHat:

cat /etc/issue

Red Hat Enterprise Linux Server release 5.5 (Tikanga)

Kernel \r on an \m

Centos:(我在Centos7.2中执行该命令后却没有出现想要的结果)

cat /etc/issue

\S

Kernel \r on an \m

Debian:(结果也不是很理想)

cat /etc/issue

Debian GNU/Linux 8 \n \l

Ubuntu:

cat /etc/issue

Ubuntu 10.04.1 LTS /n /l

还有一种方式:LSB是Linux Standard Base的缩写,lsb_release命令用来显示LSB和特定版本的相关信息。如果使用该命令时不带参数,则默认加上-v参数(在我装的Debian里测试时-v这个参数并不能使用,其他参数则正常)。

-v, --version 显示版本信息
-i, --id 显示发行版的ID
-d, --description 显示该发行版的描述信息
-r, --release 显示当前系统是发行版的具体版本号
-c, --codename 发行版代号
-a, --all 显示上面的所有信息

RedHat:

lsb_release -a

LSB Version:    :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch

Distributor ID: RedHatEnterpriseServer

Description:    Red Hat Enterprise Linux Server release 5.5 (Tikanga)

Release:        5.5

Codename:       Tikanga

Debian:

lsb_release -a

No LSB modules are available.

Distributor ID: Debian

Description:    Debian GNU/Linux 8.6 (jessie)

Release:        8.6

Codename:       jessie

CentOS7在默认安装时,没有安装lsb_release。得安装后才可正常使用:

yum -y install redhat-lsb
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: