有多种方式查看当前 Debian系统 的版本信息,这里我们会分别介绍。最简单的查看方法,是查看 /etc/issue 这个文件,样例如下;
root@debian:~# cat /etc/issue
Debian GNU/Linux 9 \n \l
上面的命令有个小问题,它没有显示 Debian 的小版本号。要获取 Debian 的小版本号 Point Release 信息,我们可以使用以下这几个命令。
joseph@debian:~$ cat /etc/debian_version
9.9
/etc/debian_version 提供了完整的版本信息。另一个文件,则会提供更详细的版本信息,文件名是 /etc/os-release,样例如下;
joseph@debian:~$ cat /etc/os-release
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/"
笔者常用的查看版本信息的命令是 lsb_release ,系统默认可能没有这个软件包。使用前,需要先安装,命令如下;
# apt-get install lsb-release
lsb_release 命令的输出样例为如下,
joseph@debian:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.9 (stretch)
Release: 9.9
Codename: stretch
Systemd 中附带的命令 hostnamectl 也可以用来查看版本信息,样例;
joseph@debian:~$ hostnamectl
Static hostname: debian
Icon name: computer-vm
Chassis: vm
Machine ID: ec27d3592320f9a20f18f50f332019b1
Boot ID: 82975e6427c048f888e0a170f6d78813
Virtualization: kvm
Operating System: Debian GNU/Linux 9 (stretch)
Kernel: Linux 4.9.0-9-amd64
Architecture: x86-64