UNIX/Linux uname命令示例

uname 命令显示系统信息。
除了主机名命令,我们还可以使用“uname -n”命令来显示我们系统的主机名。
没有任何标志,uname 命令将显示我们正在使用的操作系统。
以下是一些有用的选项:

选项描述
-a显示所有信息
-s显示内核名称
-n显示网络节点(又名主机名)
-r显示内核的发行版本
-v显示内核的版本(日期)
-m显示机器硬件名称(通常与 -p 相同)
-p显示处理器类型(通常与 -m 相同)
-o显示操作系统

uname 命令有助于检查 Linux 版本和系统信息,例如使用 uname 命令可以检查操作系统详细信息、内核版本、操作系统架构,无论是 32 位还是 64 位等等。
因此,让我们继续并通过示例来看看 uname Linux 命令。

  1. 只需检查我们当前使用的操作系统,我们只需使用以下命令即可。
# uname   # Check the Operating System
Linux
  1. 我们还可以使用带有参数 -s 的 uname 命令来检查我们当前的操作系统名称。
    参考下面的命令。
# uname -s
Linux

通过使用 uname Linux 命令,我们可以检查 Linux 版本并获取以下系统信息,例如:

  • 操作系统名称
  • 系统主机名
  • 内核版本
  • 操作系统架构例如:32位或者64位
  • 内核发布和编译日期和时间
  1. 要获得上述所有详细信息,我们可以使用带有参数 -a 的 uname 命令。
    参考下面的命令。
# uname -a   # Check all System Information
Linux localhost.localdomain 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
  1. 使用带有参数 -n 的 uname linux 命令检查操作系统的主机名或者网络名称。
# uname -n   # Check the Hostname of the System
localhost.localdomain
  1. 要检查内核发布版本,只需使用带有参数 -r 的 uname Linux 命令。
    这里我的内核版本是 2.6.32-431.el6.x86_64.
# uname -r   # Check Kernel Version
2.6.32-431.el6.x86_64
  1. 我们可以使用带有参数 -m 的 uname Linux 命令检查系统的机器硬件类型。
    参考下面的命令。
# uname -m   # Check the Hardware type
x86_64
  1. 要检查处理器类型,请使用以下命令。
    这里我们使用的是 x86_64 处理器类型。
# uname -p   # Check the Processor Type
x86_64
  1. 要检查硬件平台,请使用带有参数 -i 的 uname Linux 命令。
# uname -i   # Check the Hardware Platform
x86_64
  1. 要检查当前操作系统,请使用带有参数 -o 的 uname Linux 命令。
    正如我们在下面看到的输出,我们目前使用的是 GNU/Linux 操作系统
# uname -o   # Check the Operating System
GNU/Linux
  1. 要检查带有日期和时间的内核编译版本,请使用带有参数 -v 的 uname 命令。
    正如你在下面看到的,这个命令的输出是 #1 SMP Fri Nov 22 03:15:09 UTC 2013.
    这里内核是第一次编译,因此它显示 #1.
# uname -v   # Check Kernel compiled version
#1 SMP Fri Nov 22 03:15:09 UTC 2013

有关带有所有可用参数的 uname Linux 命令的更多信息,我们可以使用以下命令访问帮助页面。

# uname --help   # Access the Help Page
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

检查已安装的 uname 包版本只需使用以下命令。
输出将显示作者姓名、软件包发布日期、许可证详细信息、此软件包的官方网站等等。

# uname --version   # Check Package Version
uname (GNU coreutils) 8.4
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by David MacKenzie.
日期:2020-09-17 00:12:51 来源:oir作者:oir