查看Linux系统版本的命令的方法

1、各版本通用的方法,查看 /etc/os-release 文件

1
cat /etc/os-release

2、使用lsb_release -a命令【Linux Standard Base】(适用于RedHat、SUSE、Debian…等发行版,需安装 lsb-release 包)

如果运行命令提示不可用,需先安装对应包:

  • Debian/Ubuntu: sudo apt install lsb-release
  • CentOS/RHEL: sudo yum install redhat-lsb-core
1
2
3
4
5
6
[root@tv1ccmsbccolrjg ~]$lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.9.2009 (Core)
Release: 7.9.2009
Codename: Core

参考博文:查看Linux系统版本