[Linux]查看linux当前版本 How to check Linux version?

我发现百度搜出来的结果多多少少只有一种,就是cat /etc/issue。但是因为最近在做docker,所以发现部分容器的镜像可能采用的是比较简易的轻量级Linux环境(有mini, kit之类的)。这些环境可能没有etc/issue,所以记录一下其他的方法。

1. lsb_release command(2种)

$ lsb_release -a

Output:
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 9.5 (stretch)
Release:	9.5
Codename:	stretch



$ lsb_release -d

Output:
Description:	Debian GNU/Linux 9.5 (stretch)

2. /etc/os-release file

$ cat /etc/os-release

Output:
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"



$ cat /etc/issue

Output:
Debian GNU/Linux 9 \n \l

3. hostnamectl command

$ hostnamectl

Output:
	Static hostname: debian9.localdomain
         Icon name: computer-vm
           Chassis: vm
        Machine ID: a92099e30f704d559adb18ebc12ddac4
           Boot ID: 7607cbe605d44f638d6542d4c7b3878e
    Virtualization: qemu
  Operating System: Debian GNU/Linux 9 (stretch)
            Kernel: Linux 4.9.0-8-amd64
      Architecture: x86-64

4. uname command

我是其他几个都用不了,但是这个可以用,然后获取版本去linux开源找,发现是kit。然后我在container里面连按两次tab(Linux环境下,这个操作可以查看所有可以使用的command) 发现,虽然是alpine,但是很多指令都用不了。本来打算用curl,但是他不提供任何安装方法。所以选择用wget,download文件下来用里面的md5sum加密,然后用下面的命令切割出md5部分

md5sum filename|cut -d" " -f1
$ uname -srm

Output:
Linux 4.9.0-8-amd64 x86_64

5. /etc/*release

$ cat /etc/*release

英文网址:https://linuxize.com/post/how-to-check-linux-version/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值