个性化阅读
专注于IT技术分析

如何使用CLI检查Ubuntu Server 16.04中的系统规格

点击下载

本文概述

作为服务器管理员, 你将需要提供报告并检查Providen服务器是否满足运行某些应用程序所需的条件。与带有图形界面的操作系统不同, 在Ubuntu中, 没有预装工具来了解运行OS的计算机的规格, 但是有一个很棒的工具lswh, 它使你可以检索有关服务器硬件的大量信息。用非常短的命令。

在本文中, 我们将教你如何使用lshw进一步了解Ubuntu 16.04中服务器的硬件。

1.安装lshw(Linux的硬件LiSter)

lshw是一个小工具, 可提供有关计算机硬件配置的详细信息。它可以报告具有DMI功能的x86或EFI(IA-64)系统以及某些ARM和PowerPC机器上的确切内存配置, 固件版本, 主板配置, CPU版本和速度, 缓存配置, 总线速度等(PowerMac G4是知道工作)。该信息可以以纯文本, XML或HTML输出。它目前支持DMI(仅x86和EFI), OpenFirmware设备树(仅PowerPC), PCI / AGP, ISA PnP(x86), CPUID(x86), IDE / ATA / ATAPI, PCMCIA(仅在x86上进行测试), USB和SCSI。

要在你的ubuntu系统上安装此软件包, 请运行以下命令:

sudo apt-get install lshw

安装后, 你将能够以HTML格式或纯文本形式列出服务器的所有规格。有关此项目的更多信息, 请访问此处的官方资源库。

2.生成内联简短规格列表

对于几乎每个使用此工具的用户来说, 首选的方式都是简短地列出我们感兴趣的组件的描述和值, 即处理器, RAM, 存储容量和网络信息。 lshw允许你使用以下命令查看此类说明:

sudo lshw -short

这将产生类似于以下内容的输出:

H/W path        Device     Class       Description
==================================================
                           system      VirtualBox
/0                         bus         VirtualBox
/0/0                       memory      128KiB BIOS
/0/1                       memory      1999MiB System memory
/0/2                       processor   Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
/0/100                     bridge      440FX - 82441FX PMC [Natoma]
/0/100/1                   bridge      82371SB PIIX3 ISA [Natoma/Triton II]
/0/100/1.1                 storage     82371AB/EB/MB PIIX4 IDE
/0/100/2                   display     VirtualBox Graphics Adapter
/0/100/3        eth0       network     82540EM Gigabit Ethernet Controller
/0/100/4                   generic     VirtualBox Guest Service
/0/100/5                   multimedia  82801AA AC'97 Audio Controller
/0/100/7                   bridge      82371AB/EB/MB PIIX4 ACPI
/0/100/8        eth1       network     82540EM Gigabit Ethernet Controller
/0/100/d                   storage     82801HM/HEM (ICH8M/ICH8M-E) SATA Controll
/0/3            scsi2      storage
/0/3/0.0.0      /dev/sda   disk        68GB VBOX HARDDISK
/0/3/0.0.0/1    /dev/sda1  volume      487MiB Linux filesystem partition
/0/3/0.0.0/2    /dev/sda2  volume      63GiB Extended partition
/0/3/0.0.0/2/5  /dev/sda5  volume      63GiB Linux LVM Physical Volume partition

3.生成常规规格列表为HTML

如果你不足以在CLI上进行简短说明, 则lshw能够生成基于HTML的报告, 其中包含基于ubuntu的服务器的所有组件的详细说明, 只需将输出格式设置为html并将其内容传递到一个HTML文件:

sudo lshw -html > server_specs.html

然后, server_specs.html文件的内容将类似于:

Ubunto HTML详细规格

当你必须为无法访问服务器的人员提供详细说明时, 此选项非常有用。你可以简单地打印文件或将其发送给其他人。

4.生成特定的组件描述

如果需要有关系统特定组件的详细说明, 只需使用-c参数过滤指定组件所需的输出:

sudo lshw -C [component name]

例如:

网络

要显示有关网络接口的信息, 请使用:

sudo lshw -C network

这将生成类似于以下内容的输出:

*-network:0
    description: Ethernet interface
    product: 82540EM Gigabit Ethernet Controller
    vendor: Intel Corporation
    physical id: 3
    bus info: pci@0000:00:03.0
    logical name: eth0
    version: 02
    serial: 08:00:27:e8:bf:1b
    size: 1Gbit/s
    capacity: 1Gbit/s
    width: 32 bits
    clock: 66MHz
    capabilities: pm pcix bus_master cap_list ethernet physical tp 10bt 10bt-                                          fd 100bt 100bt-fd 1000bt-fd autonegotiation
    configuration: autonegotiation=on broadcast=yes driver=e1000 driverversio                                          n=7.3.21-k8-NAPI duplex=full ip=10.0.2.15 latency=64 link=yes mingnt=255 multica                                          st=yes port=twisted pair speed=1Gbit/s
    resources: irq:19 memory:f0000000-f001ffff ioport:d010(size=8)
*-network:1
    description: Ethernet interface
    product: 82540EM Gigabit Ethernet Controller
    vendor: Intel Corporation
    physical id: 8
    bus info: pci@0000:00:08.0
    logical name: eth1
    version: 02
    serial: 08:00:27:69:a2:01
    size: 1Gbit/s
    capacity: 1Gbit/s
    width: 32 bits
    clock: 66MHz
    capabilities: pm pcix bus_master cap_list ethernet physical tp 10bt 10bt-                                          fd 100bt 100bt-fd 1000bt-fd autonegotiation
    configuration: autonegotiation=on broadcast=yes driver=e1000 driverversio                                          n=7.3.21-k8-NAPI duplex=full ip=192.168.33.10 latency=64 link=yes mingnt=255 mul                                          ticast=yes port=twisted pair speed=1Gbit/s
    resources: irq:16 memory:f0820000-f083ffff ioport:d240(size=8)

存储(分区)

要显示有关系统中存储容量和分区的信息, 请使用:

sudo lshw -C volume

这将生成类似于以下内容的输出:

*-volume:0
    description: Linux filesystem partition
    vendor: Linux
    physical id: 1
    bus info: scsi@2:0.0.0, 1
    logical name: /dev/sda1
    logical name: /boot
    version: 1.0
    serial: 9ff6ec2f-4052-4861-a546-f31e7a95c11b
    size: 487MiB
    capacity: 487MiB
    capabilities: primary bootable extended_attributes large_files ext2 initialized
    configuration: filesystem=ext2 lastmountpoint=/boot modified=2018-07-01 19:24:44 mount.fstype=ext2 mount.options=rw, relatime, block_validity, barrier, user_xattr, acl mounted=2018-07-01 19:24:44 state=mounted
*-volume:1
    description: Extended partition
    physical id: 2
    bus info: scsi@2:0.0.0, 2
    logical name: /dev/sda2
    size: 63GiB
    capacity: 63GiB
    capabilities: primary extended partitioned partitioned:extended
    *-logicalvolume
        description: Linux LVM Physical Volume partition
        physical id: 5
        logical name: /dev/sda5
        serial: eSLg7t-nBsZ-fJT4-gDq4-s70Z-1Cg5-rIwDUX
        size: 63GiB
        capacity: 63GiB
        capabilities: multi lvm2

处理器

要显示有关处理器的信息, 请使用:

sudo lshw -C processor

这将生成类似于以下内容的输出:

*-cpu
    product: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
    vendor: Intel Corp.
    physical id: 2
    bus info: cpu@0
    width: 64 bits
    capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp x86-64 constant_tsc rep_good nopl xtopology nonstop_tsc pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt aes xsave avx rdrand hypervisor lahf_lm fsgsbase

声音

要显示有关声卡的信息, 请使用:

sudo lshw -C sound

这将生成类似于以下内容的输出:

*-multimedia
    description: Multimedia audio controller
    product: 82801AA AC'97 Audio Controller
    vendor: Intel Corporation
    physical id: 5
    bus info: pci@0000:00:05.0
    version: 01
    width: 32 bits
    clock: 33MHz
    capabilities: bus_master
    configuration: driver=snd_intel8x0 latency=64
    resources: irq:21 ioport:d100(size=256) ioport:d200(size=64)

记忆

要显示有关RAM内存的信息, 请使用:

sudo lshw -C memory

这将生成类似于以下内容的输出:

*-firmware
    description: BIOS
    vendor: innotek GmbH
    physical id: 0
    version: VirtualBox
    date: 12/01/2006
    size: 128KiB
    capabilities: isa pci cdboot bootselect int9keyboard int10video acpi
*-memory
    description: System memory
    physical id: 1
    size: 1999MiB

如本文开头所述, lshw是一个非常不错的实用程序, 具有很多选项, 因此你也可以在此工具的手册页中对其进行更多了解。

编码愉快!

赞(0)
未经允许不得转载:srcmini » 如何使用CLI检查Ubuntu Server 16.04中的系统规格

评论 抢沙发

评论前必须登录!