随笔 - 6  文章 - 124  评论 - 1  阅读 - 13042

Linux 如何查看当前系统版本的详细信息?

一、通过发行版的特定文件查看

发行版的说明文件一般位于 /etc 目录下面文件名包含:release 字样的文件

查看 CentOS, Red Hat 的版本

cat /etc/centos-release
# Example: CentOS Linux release 7.9.2009 (Core)

cat /etc/redhat-release
# Example: Red Hat Enterprise Linux Server release 8.5 (Ootpa)

查看 DebianUbuntu 的版本

cat /etc/debian_version

cat /etc/os-release
# Example:
# PRETTY_NAME="Ubuntu 22.04.3 LTS"
# VERSION="22.04.3 LTS (Jammy Jellyfish)"

cat /etc/issue
# Example: Ubuntu 22.04.3 LTS \n \l

查看 Fedora 的版本

cat /etc/fedora-release
# Example: Fedora release 38 (Thirty Eight)

二、使用 lsb_release 命令查看

lsb_release 命令以标准的方式提供详细的发行版信息

如果没有安装先安装

sudo apt install lsb-release  # Debian/Ubuntu
sudo yum install redhat-lsb   # CentOS/RHEL

用法:

lsb_release -a

# Output:
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:        22.04
Codename:       jammy

三、使用 hostnamectl 命令查看

hostnamectl 命令是包含在 systemd 工具套件的里面的

用法:

hostnamectl

# Output:
   Static hostname: myserver
         Icon name: computer-vm
           Chassis: vm
        Machine ID: xxxxxxxxxxxxx
           Boot ID: xxxxxxxxxxxxx
  Operating System: Ubuntu 22.04.3 LTS
            Kernel: Linux 5.15.0-79-generic
      Architecture: x86_64

四、使用 uname 命令查看

uname 一般用来查看 Linux 内核版本

用法:

uname -a

# Output:
Linux myserver 5.15.0-79-generic #86-Ubuntu SMP Wed Sep 27 15:51:31 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

五、使用 neofetchscreenfetch 命令查看

安装:

sudo apt install neofetch   # Debian/Ubuntu
sudo yum install neofetch   # CentOS/RHEL

sudo apt install screenfetch   # Debian/Ubuntu
sudo yum install screenfetch   # CentOS/RHEL

用法:

neofetch

screenfetch

六、使用 /etc/os-release 文件查看

/etc/os-release 文件在现代化 Linux 系统中基本都存在,所以是一种标准的获取系统信息的方式
用法:

cat /etc/os-release

七、使用 sw_vers 命令可查看 Mac 版本信息

sw_vers
posted on   我是唐青枫  阅读(186)  评论(0编辑  收藏  举报
编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示