Linux shell编程学习笔记45:uname命令-获取Linux系统信息

0 前言

linux 有多个发行版本,不同的版本都有自己的版本号。

如何知道自己使用的Linux的系统信息呢?

使用uname命令、hostnamectl命令,或者通过查看/proc/version文件来了解这些信息。

我们先看看uname命令。

1 uname 命令的功能和格式

我们可以使用命令 uname --help命令 查看它的用法:

purpleEndurer @  bash ~ $ uname --help
Usage: uname [OPTION]...
Print certain system information.  With no OPTION, same as -s.

  -a, --all                print all information, in the following order,
                             except omit -p and -i if unknown:
  -s, --kernel-name        print the kernel name
  -n, --nodename           print the network node hostname
  -r, --kernel-release     print the kernel release
  -v, --kernel-version     print the kernel version
  -m, --machine            print the machine hardware name
  -p, --processor          print the processor type or "unknown"
  -i, --hardware-platform  print the hardware platform or "unknown"
  -o, --operating-system   print the operating system
      --help     display this help and exit
      --version  output version information and exit

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Report uname translation bugs to <http://translationproject.org/team/>
For complete documentation, run: info coreutils 'uname invocation'

 

 

1.1 uname命令的功能

uname命令的功能是显示操作系统信息,例如内核版本、主机名、处理器类型等。

1.2 uname命令的格式

uname [选项] ...

 1.2.1 选项说明

选项 描述 备注
-a, --all 以如下次序输出所有信息。 其中若-p 和-i的探测结果不可知则被省略

-s

--kernel-name

输出内核名称 -

-n

--nodename

输出网络节点上的主机名 -
-r, --kernel-release 输出内核发行号 -

-v

--kernel-version

输出内核版本 -

-m

--machine

输出机器硬件名 -

-p

--processor

输出处理器类型 非移动

-i

--hardware-platform

输出硬件平台 非移动

-o

--operating-system

输出操作系统 -
--help 显示此帮助信息并退出 -
--version 显示版本信息并退出 -

1.2.2 注意

如果不指定选项,则系统默认选项为-s,即只显示内核名称。

2 uname命令使用实例 

2.1 uname 或 uname -s:显示内核名称

purpleEndurer @  bash ~ $ uname
Linux

purpleEndurer @  bash ~ $ uname -s
Linux

 

2.2  uname -n:输出网络节点上的主机名

purpleEndurer @  bash ~ $ uname -n
edu

2.3 uname -r:输出内核发行号

purpleEndurer @  bash ~ $ uname -r
5.10.134-15.1.2.lifsea8.x86_64

2.4 uname -v:输出内核版本

purpleEndurer @  bash ~ $ uname -v
#1 SMP Tue Aug 29 07:26:14 UTC 2023

 2.5 uname -m:输出机器硬件名

purpleEndurer @  bash ~ $ uname -m
x86_64

2.6 uname -p:输出处理器类型

purpleEndurer @  bash ~ $ uname -p
x86_64

2.7 uname -i:输出硬件平台

purpleEndurer @  bash ~ $ uname -i
x86_64

2.8 uname -o:输出操作系统

purpleEndurer @  bash ~ $ uname -o
GNU/Linux

2.9 uname -a:输出所有信息

purpleEndurer @  bash ~ $ uname -a
Linux edu 5.10.134-15.1.2.lifsea8.x86_64 #1 SMP Tue Aug 29 07:26:14 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

相关推荐

  1. LinuxShell编程中source和export命令

    2024-04-02 06:54:03       17 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-04-02 06:54:03       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-02 06:54:03       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-02 06:54:03       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-02 06:54:03       18 阅读

热门阅读

  1. 给手机换电池、贴膜:VIVO服务还是非常好的

    2024-04-02 06:54:03       55 阅读
  2. R语言基础入门教程

    2024-04-02 06:54:03       13 阅读
  3. Linux 安装apache

    2024-04-02 06:54:03       15 阅读
  4. docker搭建Linuxserver/tvheadend

    2024-04-02 06:54:03       14 阅读
  5. vue3从精通到入门8:reactive的使用

    2024-04-02 06:54:03       16 阅读
  6. Day5-

    Day5-

    2024-04-02 06:54:03      11 阅读
  7. cesium键盘控制相机位置和姿态

    2024-04-02 06:54:03       10 阅读
  8. Jenkins插件下载错误时间问题

    2024-04-02 06:54:03       11 阅读