linux 获取版本信息,Linux下获取系统版本信息的方法

原创内容,转载请注明出处: https://www.myzhenai.com.cn/post/2472.html https://www.myzhenai.com/thread-17980-1-1.html

关键字: Linux 版本信息

Linux下获取版本信息的方法有很多, 有用cat的,也有用uname的.但我发现获取版本信息最完整的是 lsb_release

[root@localhost RucLinux]# yum install redhat-lsb -y

[root@localhost RucLinux]# lsb_release --h

FSG lsb_release v2.0 prints certain LSB (Linux Standard Base) and

Distribution information.

Usage: lsb_release [OPTION]...

With no OPTION specified defaults to -v.

Options:

-v, --version

Display the version of the LSB specification against which the distribution is compliant.

-i, --id

Display the string id of the distributor.

-d, --description

Display the single line text description of the distribution.

-r, --release

Display the release number of the distribution.

-c, --codename

Display the codename according to the distribution release.

-a, --all

Display all of the above information.

-s, --short

Use short output format for information requested by other options (or version if none).

-h, --help

Display this message.

[root@localhost RucLinux]# lsb_release -a

LSB Version::base-4.0-ia32:base-4.0-noarch:core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4.0-noarch

Distributor ID:CentOS

Description:CentOS release 6.8 (Final)

Release:6.8

Codename:Final

# !/bin/bash

release=`cat /etc/centos-release`

#version=`lsb_release -a|grep -e Dist -e Release|awk -F ":" '{ print $2 }'`

#version=`lsb_release -a|grep -e Release|awk -F ":" '{ print $2 }'`

#version=`lsb_release -a|grep -e Dist|awk -F ":" '{ print $2 }'`

version=`lsb_release -a|grep -e Release|awk -F ":" '{ print $2 }'|awk -F "." '{ print $1 }'|sed 's/ //g'`

#获取到系统版本号的前一位 这里获取到的是6.8中的6

version=`lsb_release -a|grep -e Release|awk -F ":" '{ print $2 }'|sed 's/ //g'`

#获取到系统版本号, 这里获取到的是6.8

version=`lsb_release -a|grep -e ID|awk -F ":" '{ print $2 }'|sed 's/ //g'`

#获取到Distributor ID列中的系统版本名称

version=`lsb_release -a|grep -e Description|awk -F ":" '{ print $2 }'|sed 's/ //g'`

#获取到Description列中的系统版本名称

if [ $version == "6" ];then

echo $version

fi

#echo $release

88e94ecdedb0ffa063d04eae5f392c4f.png

93d2eb9ffd0ff4116400d1e42107442e.png

sicnature ---------------------------------------------------------------------

Your current IP address is: 222.191.176.10

Your IP address location: 江苏省无锡市电信

Your IP address country and region: 中国

d9840db1de5c066b3143a36b83ba0940.png

Your current browser is:

c55e3eff36f0c380a04e3e5ffee3bbca.png

Your current system is:

mac.png

Original content, please indicate the source:

同福客栈论坛 | 蟒蛇科普 | 海南乡情论坛 | JiaYu Blog

sicnature ---------------------------------------------------------------------

Welcome to reprint. Please indicate the source https://www.myzhenai.com.cn/post/2472.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值