---
title: "我使用过的Linux命令之uname - 打印系统信息"
author: "codingstandards"
date: "2010-11-11T20:26:52Z"
tags: ["Blog", "GCC", "Linux", "RedHat", "脚本"]
categories: ["操作系统"]
slug: "linux-uname"
draft: false
lastmod: "2010-11-11T20:27:28Z"
id: 809182
url: "https://codingstandards.iteye.com/blog/809182"
---

# 我使用过的Linux命令之uname - 打印系统信息

本文链接：[http://codingstandards.iteye.com/blog/809182](/blog/809182)   （转载请注明处处）

## 用途说明

uname命令用来打印系统信息（print system information），包括系统名称、内核版本等重要信息。美中不足的是无法打印Linux发行版本的名称，比如打印RHEL5.5或CentOS5.5之类的，另外一个命令lsb\_release可以打印这些。相关资料【2】中提供了一些别的方法可以取得系统版本信息。

## 常用参数

-a 打印全部系统信息。

-r 打印内核发行版本。

在脚本中可以使用 \`uname -r\` 或者 $(uname -r) 取得内核发行版本，比如2.4.18。

## 使用示例

### 示例一 打印使用方法

\[root@web186 root]# uname --help  
用法：uname \[选项]...  
Print certain system information.  With no OPTION, same as -s.

  -a, --all                print all information, in the following order:  
  -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  
  -i, --hardware-platform  print the hardware platform  
  -o, --operating-system   print the operating system  
      --help     显示此帮助信息并离开  
      --version  显示版本信息并离开

Report bugs to &lt;bug-coreutils@gnu.org&gt;.  
\[root@web186 root]#

### 示例二 在RHEL5.5下的结果

\[root@new55 ~]# uname  
Linux  
\[root@new55 ~]# uname -a  
Linux new55 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:43 EDT 2010 i686 i686 i386 GNU/Linux  
\[root@new55 ~]# uname -s  
Linux  
\[root@new55 ~]# uname -m  
i686  
\[root@new55 ~]# uname -i  
i386  
\[root@new55 ~]# uname -n  
new55  
\[root@new55 ~]# uname -v  
#1 SMP Tue Mar 16 21:52:43 EDT 2010  
\[root@new55 ~]# uname -r

2.6.18-194.el5

 

### 示例三 其他显示系统版本信息的方法

\[root@new55 ~]# cat /proc/version  
Linux version 2.6.18-194.el5 (mockbuild@x86-007.build.bos.redhat.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Tue Mar 16 21:52:43 EDT 2010  
\[root@new55 ~]# cat /etc/issue  
Red Hat Enterprise Linux Server release 5.5 (Tikanga)  
Kernel \\r on an \\m

\[root@new55 ~]# cat /etc/redhat-release  
Red Hat Enterprise Linux Server release 5.5 (Tikanga)  
\[root@new55 ~]#  
\[root@new55 ~]# lsb\_release -a  
LSB Version:    :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch  
Distributor ID: RedHatEnterpriseServer  
Description:    Red Hat Enterprise Linux Server release 5.5 (Tikanga)  
Release:        5.5  
Codename:       Tikanga  
\[root@new55 ~]#

## 问题思考

## 相关资料

【1】时光漂流瓶 不要抱怨，而要改变,不要抛弃,不要放弃 [Linux系统下的uname命令](http://www.9usb.net/200911/linux-uname-mingling.html)

【2】10V 干一行，爱一行 [《uname命令》－linux命令五分钟系列之五](http://www.smartwei.com/linux-uname-instruction.html)

 

返回 [我使用过的Linux命令系列总目录](/blog/786653)