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

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: command 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.org) (gcc 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) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #185-Ubuntu SMP Tue Mar 29 17:40:04 UTC 2022
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

CV温故知新

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值