Linux下命令查看区分ubuntu、centos操作系统

家电修理 2023-07-16 19:16www.caominkang.com电器维修

Linux下有时需要根据系统类型是centos,或ubuntu,从而进行选择不同的命令执行,
有下面几种命令可以确定系统类型

  1. lsb_release -a
  2. cat /etc/redhat-release
  3. cat /etc/issue
  4. cat /proc/version

下图是在centos系统几种命令的输出

[root@localhost]# lsb_release -a
bash: lsb_release: mand not found...

[root@localhost]# cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)

[root@localhost]# cat /etc/issue
S
Kernel r on an m

[root@localhost]# cat /proc/version
Linux version 3.10.0-1127.el7.x86_64 (mockbuild@kbuilder.bsys.centos.) (g version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) ) #1 SMP Tue Mar 31 23:36:51 UTC 2020

下图是在ubuntu系统几种命令的输出

root@ubuntu:/home# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release:  18.04
Codename:    bionic

root@ubuntu:/home# cat /etc/redhat-release
cat: /etc/redhat-release: No such file or directory

root@ubuntu:/home# cat /etc/issue
Ubuntu 18.04.2 LTS n l

root@ubuntu:/home# cat /proc/version
Linux version 4.15.0-176-generic (buildd@lcy02-amd64-020) (g version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #185-Ubuntu SMP Tue Mar 29 17:40:04 UTC 2022

Copyright © 2016-2025 www.caominkang.com 曹敏电脑维修网 版权所有 Power by