前言
1、當我們拿到一個 Linux 服務器的時候,我怎么知道他是 centos 系統,還是 ubantu 系統?
2、如果知道是 centos系統了,那我怎么知道他是 centos7.6還是 centos8.0 還是其它的版本?
lsb_release 查看系統
先使用 yum 安裝 redhat-lsb:
yum install -y redhat-lsb
安裝完成后,使用 -a 查看
[root@yoyo ~] lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.6.1810 (Core) Release: 7.6.1810 Codename: Core
於是我們就可以知道是 centos 7.6版本。
redhat-release
如果已經知道是 centos 系統了,可以直接 cat 查看版本號:
[root@yoyo ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core)
uname 查看內核版本
查看內核版本可以用 uname -a
[root@yoyo ~]# uname -a Linux iZ2vchn8sk983jm605yhshZ 3.10.0-957.21.3.el7.x86_64 #1 SMP Tue Jun 18 16:35:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
也可以 cat /proc/version
[root@iZ2vchn8sk983jm605yhshZ ~]# cat /proc/version Linux version 3.10.0-957.21.3.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Tue Jun 18 16:35:19 UTC 2019