查找硬件信息的Linux命令是什么?


96

我需要查找Linux下以下各项的硬件信息:

  • CPU(和核心)
  • CPU速度
  • 记忆
  • 硬碟
  • 操作系统版本

有什么建议吗?


HardInfo是一个不错的GUI工具。
地毯

Answers:


96

Linux命令-实用参考

显示内核版本和系统架构

uname -a

显示发行名称和版本

head -n1 /etc/issue

显示系统上注册的所有分区

cat /proc/partitions

显示系统看到的RAM总数

grep MemTotal /proc/meminfo

显示CPU信息

grep "model name" /proc/cpuinfo

显示有关磁盘sda的信息

hdparm -i /dev/sda

41

尝试 lshw

它将建议您将其运行为root,因此请尝试

sudo lshw

1
您将需要在很多情况下安装它-iirc ubuntu中没有库存
Journeyman Geek

在kali linux上同样的问题!
Kunok

36

以下是在Linux上检查硬件的命令列表。请注意,并非所有命令在所有发行版上都可用。最好先以root身份启动(或通过sudo)以获取所有信息。

命令:lscpu

  • 列出可用的cpus及其特征
  • 不适用于较早的发行版

命令:lshal

  • 需要安装HAL(硬件抽象层)
  • 列出HAL可见的所有硬件

命令:lshw

  • 默认情况下在基于Ubuntu的发行版中可用,在主仓库中可用Debian
  • 在Fedora存储库中可用
  • 使用许多输入来检测所有硬件:内核,HAL,DMI等。
  • 作为生成硬件报告的简洁的“ -html”开关
  • 在此页面上查看更多

命令:lspci

  • 标准指令
  • 列出内核检测到的连接到PCI总线的所有硬件

命令:lsusb

  • 标准指令
  • 列出内核检测到的连接到USB总线的所有硬件

命令:dmidecode

  • 标准指令
  • 从DMI(一种BIOS界面)获取源信息
  • 列出DMI接口报告的所有硬件

13

我是一个实用程序的联合开发人员,该实用程序已进入多个发行版。该工具称为inxi。它是一个bash脚本,可以通过一个简单的命令完成所有其他答案。看看这个。

要使用它,只需转到终端并键入'inxi -F',它将显示完整的(-F)系统信息输出。'inxi -h'将显示更多选项。它最初是为IRC故障排除而设计的,因此它几乎可以在所有IRC客户端中使用(并捆绑在某些客户端中)。

xi



9

而且,只要加上我的两分钱,我也会尝试

hwinfo

在使用完整命令之前,您可以尝试使用简短版本,

hwinfo --short

可能已经提供了您要搜索的信息。fll版本的细节非常丰富,因此最好用

hwinfo | more

并且,顺便说一句,可以通过以下方式获得lshw提供的信息的便捷压缩形式:

sudo lshw -businfo

具有易于阅读的输出:

Bus info          Device      Class          Description
========================================================
                              system         PORTEGE R930 (PT331E)
                              bus            PORTEGE R930
                              memory         128KiB BIOS
                              memory         6GiB System Memory
                              memory         4GiB SODIMM DDR3 Synchronous 1600 MHz (0,6 ns)
                              memory         2GiB SODIMM DDR3 Synchronous 1600 MHz (0,6 ns)
cpu@0                         processor      Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz
                              memory         32KiB L1 cache
                              memory         256KiB L2 cache
                              memory         4MiB L3 cache
                              memory         32KiB L1 cache
pci@0000:00:00.0              bridge         3rd Gen Core processor DRAM Controller
pci@0000:00:02.0              display        3rd Gen Core processor Graphics Controller
pci@0000:00:14.0              bus            7 Series/C210 Series Chipset Family USB xHCI     Host Controller
pci@0000:00:16.0              communication  7 Series/C210 Series Chipset Family 
                                             MEI Controller #1
pci@0000:00:16.3              communication  7 Series/C210 Series Chipset Family KT Controller
pci@0000:00:19.0  eth0        network        82579LM Gigabit Network Connection
pci@0000:00:1a.0              bus            7 Series/C210 Series Chipset Family USB Enhanced Host Controller #2
pci@0000:00:1b.0              multimedia     7 Series/C210 Series Chipset Family High Definition Audio Controller
pci@0000:00:1c.0              bridge         7 Series/C210 Series Chipset Family PCI Express Root Port 1
pci@0000:01:00.0              generic        MMC/SD Host Controller
pci@0000:00:1c.1              bridge         7 Series/C210 Series Chipset Family PCI Express Root Port 2
pci@0000:00:1c.2              bridge         7 Series/C210 Series Chipset Family PCI Express Root Port 3
pci@0000:04:00.0  wlan0       network        Centrino Advanced-N 6235
pci@0000:00:1c.5              bridge         7 Series/C210 Series Chipset Family PCI Express Root Port 6
pci@0000:00:1d.0              bus            7 Series/C210 Series Chipset Family USB Enhanced Host Controller #1
pci@0000:00:1f.0              bridge         QM77 Express Chipset LPC Controller
pci@0000:00:1f.2              storage        7 Series Chipset Family 6-port SATA Controller [AHCI mode]
                 scsi0       storage        
scsi@0:0.0.0      /dev/sda    disk           256GB TOSHIBA THNSNF25
scsi@0:0.0.0,1    /dev/sda1   volume         27GiB EXT4 volume
scsi@0:0.0.0,2    /dev/sda2   volume         210GiB Extended partition
                 /dev/sda5   volume         5722MiB Linux swap / Solaris partition
                 /dev/sda6   volume         204GiB Linux filesystem partition
                 scsi2       storage        
scsi@2:0.0.0      /dev/cdrom  disk           DVD-RAM UJ8C2
                             power          Lithium Ion Battery
                          power          
                 wwan0       network        Ethernet interface

还有一个lshw的图形版本,称为lshw-gtk:

sudo lshw-gtk &

根据您所使用的特定发行版,可能需要安装其中大多数命令(apt-get install,yum,pacman等)。


2

还有一个流行的非标准脚本(需要安装),称为screenFetch

screenFetch是“ Bash屏幕截图信息工具”。这个方便的Bash脚本可用于生成您现在在每个人的屏幕快照中看到的那些漂亮的终端主题信息+ ASCII分发徽标之一。它将自动检测您的发行版,并在右侧显示该发行版徽标的ASCII版本和一些有价值的信息。有一些选项可以指定不使用ASCII文字,颜色,在显示信息时进行屏幕截图,甚至自定义屏幕截图命令!该脚本非常容易添加,并且可以轻松扩展。

在此处输入图片说明


1
好东西!但是,仅供参考,如果它是活动软件并且当前可用,则始终倾向于链接到官方网站,或者在这种情况下,链接到官方网站。
JakeGould '18年

1

如果您需要有关通过PCI(或PCI-Express)总线连接到计算机的所有设备的大量信息,请键入 lspci -vvknnqq

如果需要有关磁盘分区的信息,请键入 sudo fdisk -l /dev/sda



1

如果您使用p来管理基础结构,请使用事实

facter processorcount sp_number_processors sp_current_processor_speed memorytotal operatingsystem  osfamily operatingsystemrelease

processorcount => 4
sp_current_processor_speed => 2.5 GHz
sp_number_processors => 2
memorytotal => 8.00 GB
osfamily => RedHat
operatingsystem => CentOS
operatingsystemrelease => 6.5

您甚至可以输出为yaml或json

facter osfamily operatingsystem --json
{"osfamily":"Darwin","operatingsystem":"Darwin"}

facter osfamily operatingsystem --yaml
osfamily: Darwin
operatingsystem: Darwin

厨师有一个类似的工具叫做ohai


0

HW-探针工具一次收集所有的硬件相关的制表的输出(HWINFO,lspci的,lscpu,hdparm的,smartctl读取,的dmidecode等)。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.