如何查看您机器上当前安装的 Linux 版本?

linuxubuntuoperating system

您是 Linux/Ubuntu 新手吗?您知道您的机器上当前安装的是哪个版本的 Ubuntu/Linux 吗?如果您正为之困惑,那么本文将向您介绍如何查看您机器上当前安装的 Linux 版本。

方法 1

使用以下命令查找 Ubuntu 版本,如下所示 −

$cat /etc/*-release

示例输出应如下所示 –

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.1 LTS"
NAME="Ubuntu"
VERSION="16.04.1 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.1 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/"
UBUNTU_CODENAME=xenial

要获取 Linux 机器的内核信息,请使用以下命令,如下所示 −

$ hostnamectl

示例输出应如下所示 −

Static hostname: tutorialspoint-Inspiron-3541
Icon name: computer-laptop
Chassis: laptop
Machine ID: 5723a90b27e94b9f857fa8eb5b69d189
Boot ID: dbf579d74c9740c7a180cf00f760b4e1
Operating System: Ubuntu 16.04.1 LTS
Kernel: Linux 4.4.0-31-generic
Architecture: x86-64

方法 2

使用以下命令获取 Linux 内核信息,如下所示

$ uname -mrs

示例输出应类似于 −

Linux 4.4.0-31-generic x86_64

方法 3

使用以下命令获取 Linux 内核信息,如下所示

$ cat /proc/version

示例输出应类似于 −

Linux 版本 4.4.0-31-generic (buildd@lgw01-16) (gcc 版本 5.3.1 20160413 (Ubuntu 5.3.1-14ubuntu2.1) ) #50-Ubuntu SMP 2016年7月13日星期三 00:07:12 UTC

方法 4

如果您使用 Python,请使用以下命令获取有关 Linux 内核的信息

$python -c "import platform;print(platform.platform())"

示例输出应类似于 −

Linux-4.4.0-31-generic-x86_64-with-Ubuntu-16.04-xenial

读完本文后,您将能够了解如何查看计算机上当前安装的 Linux 版本。在接下来的文章中,我们将提供更多基于 Linux 的技巧和窍门。继续阅读!


相关文章


有用资源