02_内核那些事之uname命令

在学习过程中,首先要熟悉我们正在操作的系统环境(如:硬件环境,软件环境),那么怎么去查看操作的环境呢?在Linux操作系统中uname是个不错的选择。


1. 基本概念

  • 内核名称:GUN/Linux,
  • 主机名:主机的名称,通过hostname命令查看主机名
  • 内核发行版本:
  • 内核版本:
  • 硬件架构名称
  • CPU(处理器)类型
  • 硬件平台
  • 操作系统名称



2. uname命令详解

如果去查看uname的用法呢?在下面的操作中我通过man命令查找uname的英文帮助,来学习uname命令。


NAME: uname - print system information
SYNOPSIS: uname [OPTION]…
DESCRIPTION: Print certain system information. With no OPTION, same as -s.

命令名称: uname - 输出系统信息
命令用法: uname [选项]… 注释:[]代表选项可加可不加,...选项可多个
命令描述: 输出系统信息,当uname命令后面不跟选项时,默认是执行-s选项



  • -a选项


-a, –all: print all information, in the following order, except omit,-p and -i if unknown

-a,–all: 按顺序输出所有的系统信息,当-p和-i信息为不可知(unknown)时省略该信息.输出信息分别表示内核名称,主机名,内核发行版本, 内核版本,硬件架构名称,CPU(处理器)类型,硬件平台,操作系统名称。

[kiosk@foundation45 ~]$ uname -a
Linux foundation45.ilt.example.com 3.10.0-229.el7.x86_64 #1 SMP Thu Jan 29 18:37:38 EST 2015 x86_64 x86_64 x86_64 GNU/Linux
[kiosk@foundation45 ~]$ uname --all
Linux foundation45.ilt.example.com 3.10.0-229.el7.x86_64 #1 SMP Thu Jan 29 18:37:38 EST 2015 x86_64 x86_64 x86_64 GNU/Linux


  • -s选项


-s, –kernel-name: print the kernel name

-s, –kernel-name: 输出内核名称(eg:Unix,Linux…)

[kiosk@foundation45 ~]$ uname -s
Linux
[kiosk@foundation45 ~]$ uname --kernel-name
Linux


  • -n选项


-n, –nodename: print the network node hostname

-n, –nodename: 输出网络节点的主机名,如果在本机操作,输出与hostname命令一致

[kiosk@foundation45 ~]$ uname -n
foundation45.ilt.example.com
[kiosk@foundation45 ~]$ uname --nodename
foundation45.ilt.example.com


  • -r选项


-r, –kernel-release: print the kernel release

-r, –kernel-release: 输出内核发行版本

[kiosk@foundation45 ~]$ uname -r
3.10.0-229.el7.x86_64
[kiosk@foundation45 ~]$ uname --kernel-release 
3.10.0-229.el7.x86_64


  • -v选项


-v, –kernel-version: print the kernel version

-v, –kernel-version: 输出内核版本

[kiosk@foundation45 ~]$ uname -v
#1 SMP Thu Jan 29 18:37:38 EST 2015
[kiosk@foundation45 ~]$ uname --kernel-version 
#1 SMP Thu Jan 29 18:37:38 EST 2015


  • -m选项
    -m, –machine: print the machine hardware name


-m, –machine: 输出主机(即你的电脑或服务器)的硬件架构名称

[kiosk@foundation45 ~]$ uname -m
x86_64
[kiosk@foundation45 ~]$ uname --machine 
x86_64


  • -p选项


-p, –processor: print the processor type or “unknown”

-p, –processor: 输出CPU(处理器)类型或‘unknown’

[kiosk@foundation45 ~]$ uname -p
x86_64
[kiosk@foundation45 ~]$ uname --processor 
x86_64


  • -i选项


-i, –hardware-platform: print the hardware platform or “unknown”

-i, –hardware-platform: 输出硬件平台或‘unknow’

[kiosk@foundation45 ~]$ uname -i
x86_64
[kiosk@foundation45 ~]$ uname --hardware-platform 
x86_64


  • -o选项


-o, –operating-system: print the operating system

-o, –operating-system: 输出操作系统名称

[kiosk@foundation45 ~]$ uname -o
GNU/Linux
[kiosk@foundation45 ~]$ uname --operating-system 
GNU/Linux


  • –help选项


–help: display this help and exit
–help: 输出帮助(uanme命令用法信息)并退出

```
[kiosk@foundation45 ~]$ 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/>
For complete documentation, run: info coreutils 'uname invocation'


  • –version选项


–version: output version information and exit

–version: 输出该命令的版本信息并退出

[kiosk@foundation45 ~]$ uname --version
uname (GNU coreutils) 8.22
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值