识别CentOS和Ubuntu的系统版本
识别CentOS和Ubuntu的系统版本
1、用 lsb-release
#!/bin/bash
Install_LSB()
{
if [ "$PM" = "yum" ]; then
yum install -y redhat-lsb centos-release
elif [ "$PM" = "apt" ]; then
apt-get update
apt-get install -y lsb-release
fi
}
Install_LSB
lsb_release -d
2、从定义好的配置文件中读取
CentOS 中相关的文件
cat /etc/centos-release
cat /etc/redhat-release (/etc/redhat-release -> centos-release)
cat /etc/system-release (/etc/system-release -> centos-release)
rpm -q centos-release
# rpm -q redhat-release
如果是CentOS7,支持 cat /etc/os-release
Ubuntu 中相关的文件
cat /etc/os-release (/etc/os-release -> ../usr/lib/os-release)
cat /etc/lsb-release
在CentOS和Ubuntu中也可以这样读系统版本,不过 /etc/issue (登录欢迎信息)有时候是空的
cat /etc/issue
#cat /etc/*elease
for i in $(ls /etc/*release); do echo ===$i===; cat $i; done
3、hostnamectl
在CentOS7和Ubuntu中,通过 hostnamectl 读系统版本
hostnamectl
Ubuntu中这样安装 hostnamectl
apt install -y systemd systemd-services apt-file
apt-file update
apt-file search hostnamectl
/usr/bin/hostnamectl
识别CentOS和Ubuntu的系统版本的更多相关文章
- Ubuntu 更新系统版本以及查看当前系统版本的命令
1. Ubuntu 查看当前系统版本: lsb_release -a 2. Ubuntu 更新系统版本的命令: sudo do-release-upgrade
- 云服务器-Ubuntu更新系统版本-更新Linux内核-服务器安全配置优化-防反弹shell
购入了一台阿里云的ESC服务器,以前都用CentOS感觉Yum不怎么方便,这次选的Ubuntu16.04.7 搭好服务之后做安全检查,发现Ubuntu16.04版本漏洞众多:虽然也没有涉及到16.04 ...
- ubuntu查看系统版本和内核版本
查看系统版本: cat /etc/issue sudo lsb_release -a 查看内核版本: uname -r
- ubuntu 查看系统版本信息
查看cpu信息cat /proc/cpiinfo 查看ubuntu版本:cat /etc/issue 查看系统是32位还是64位方法1:#查看long的位数,返回32或64 getconf LONG_ ...
- ubuntu查看系统版本
1.查看文件信息,包含32-bit就是32位,包含64-bit就是64位 root@HDController:/home/nulige/tools# uname -a Linux HDControll ...
- ubuntu 查看系统版本
在终端中执行下列指令:cat /etc/issue可以查看当前正在运行的 Ubuntu 的版本号: 使用 lsb_release 命令也可以查看 Ubuntu 的版本号,与方法一相比,内容更为详细:
- Ubuntu查看系统版本的方法
1. less /etc/issue 2. less /proc/version 3. uname -a 4. lsb_release -a
- Linux下载_Linux系统各种版本ISO镜像下载(redhat,centos,oracle,ubuntu,openSUSE)
以下是风哥收集的Linux系统各种版本ISO镜像下载,包括redhat,centos,oracle,ubuntu等linux操作系统. Linux下载1:红帽RedHat Linux(RHEL5.RH ...
- 查看linux系统版本信息(Oracle Linux、Centos Linux、Redhat Linux、Debian、Ubuntu)
一.查看Linux系统版本的命令(3种方法) 1.cat /etc/issue,此命令也适用于所有的Linux发行版. [root@S-CentOS home]# cat /etc/issue Cen ...
随机推荐
- 由Request Method:OPTIONS初窥CORS(转)
刚接触前端的时候,以为HTTP的Request Method只有GET与POST两种,后来才了解到,原来还有HEAD.PUT.DELETE.OPTIONS…… 目前的工作中,HEAD.PUT.DELE ...
- git 源码安装后报错/usr/bin/git: No such file or directory
现象 今天源码安装一个git后,执行git命令后报如下错误: $ git --version -bash: /usr/bin/git: No such file or directory 分析过程 开 ...
- 越努力越幸运--2-LD_PRELOAD, fork ,僵尸进程
开始新的工作了,做了爸爸之后感觉一直都是浑浑噩噩,希望老婆和宝宝一直健康开心~ 最近遇到的问题很多啊,哈哈 1. 装环境时候,需要的glibc 版本不对,我把本地的软链接改了个别名(惯性思维),然后一 ...
- c++常见操作的模板
1.统计时间 #include<ctime> clock_t startTime = clock(); code(); clock_t endTime = clock(); cout &l ...
- python基础7(函数 Ⅱ)
1.python代码运行遇到函数时 从python解释器开始执行之后,就在内存中开辟了一个空间 每当遇到一个变量的时候,就把变量名和值之间的对应关系记录下来. 但是当遇到函数定义的时候解释器只是象征性 ...
- CAD二次开发(01)-绘制直线
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- G4Studio+extjs+highcharts 下在ext4j的panel中放入hightCharts图表
在G4Studio+extjs下.创建一个panel,然后将highCharts图表放入panel中.实现方法例如以下: 首先简单给出的部分代码: Ext.onReady(function() { v ...
- SQL的四种语言:DDL、DML、DCL、TCL
1. DDL(Data Definition Language) 数据库定义语言statements are used to define the database structure or sche ...
- CG 内置函数 和 HLSL 内置函数
CG 内置函数 英伟达官网链接: http://http.developer.nvidia.com/Cg/index_stdlib.html absacosallanyasinatan2atanbi ...
- Linux 命令行光标快速选中移动快捷键
Ctrl+Alt+T 打开终端一些常用的终端快捷键:Ctrl+L 清空屏幕(功能相当于命令clear)Ctrl+U 剪切文本直到行的起始(可以用于清空行)Ctrl+K 剪切文本直到行的末尾Ctrl+Y ...