如何通过命令行和图形界面检查我的当前Ubuntu版本?
lsb_release -a
您的版本显示在“描述”行上。如果您只想要该行,请键入lsb_release -d
。
如果您想通过桌面环境进行检查,可以查看系统设置 → 详细信息,其中显示的数据如下:
备选方案如下:
hostnamectl
cat /etc/*ease
lsb_release
、hostnamectl
和 cat /etc/*ease
命令的示例输出:$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS # <-- here
Release: 16.04
Codename: xenial
$ lsb_release -d
Description: Ubuntu 16.04.2 LTS
$ hostnamectl
Static hostname: XXX
Icon name: computer-desktop
Chassis: desktop
Machine ID: 3d6dcfdd7b9f41dbb62b0e8cd75014ae
Boot ID: 4ff04a6baed54e719592f3255005a235
Operating System: Ubuntu 16.04.2 LTS # <-- here
Kernel: Linux 4.10.0-38-generic
Architecture: x86-64
$ cat /etc/*ease
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS" # <--- here
NAME="Ubuntu"
VERSION="16.04.2 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.2 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
os -v
这样的命令呢?有点烦人。 - Charlie Parkerver
。 - kapubuntu:xenial
)没有lsb_release
命令;我不得不像另一个答案中提到的那样解析/etc/os_release
文件。 - Aaron D. Marascoexport OS_CODE_NAME=$(lsb_release -cs); export OS_CODE_VERSION=$(lsb_release -rs)
可以让你使用 env | grep OS
命令,这可能更加方便。 - spylealias os="lsb_release -a"
。我同意这应该默认更容易,但UNIX的美妙之处在于它允许您自己轻松修复此类问题。 - Austin Deanbash: lsb_release: command not found
和E: Unable to locate package lsb_release
的错误提示。 - techkuzsb_release -d | grep -ioP ':\s+\K(.+?$)'
- Agnius Vasiliauskas使用:
cat /etc/*release
DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=17.2
DISTRIB_CODENAME=rafaela
DISTRIB_DESCRIPTION="Linux Mint 17.2 Rafaela"
NAME="Ubuntu"
VERSION="14.04.3 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.3 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
cat /etc/lsb-release
- user4381/etc/upstream-release/lsb-release
也可能是感兴趣的内容。 - cheffogrep 'CODENAME' /etc/lsb-release | cut -d'=' -f2
的结果。 - Larry Cailsb_release -a
15.4
?它可以通过选项 -r
(--release
)单独显示:$ lsb_release -r
Release: 15.04
-s
(--short
)。$ lsb_release -r -s
15.04
$ lsb_release -c
Codename: vivid
$ lsb_release -d
Description: Ubuntu 15.04
$ lsb_release -dc
Description: Ubuntu 15.04
Codename: vivid
$ uname -a
Linux mybox 3.19.0-31-generic #36-Ubuntu SMP Wed Oct 7 15:04:02 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
lsb_release -r -s
是我正在寻找的,谢谢。 - Lukas Liesislsb_release -rs
和lsb_release -cs
在脚本中非常有用。 - frozen-flame
/etc/apt/sources.list
文件,并查看它从哪个仓库拉取。这是我唯一能找出我正在运行的Ubuntu镜像的方法,而我是在docker run -it --rm
命令中运行的,显然没有安装lsb_release
。 - Bratchley