在Linux系统中,查看硬件配置信息是一项非常重要的任务。了解硬件配置信息可以帮助您了解系统的性能和资源使用情况。以下是在Linux系统中查看硬件配置信息的详细攻略。
看CPU信息
要查看Linux系统中的CPU信息,可以使用以下命令:
cat /proc/cpuinfo
这个命令将显示关系统中每个CPU的详细信息,例如CPU型号、速度、缓存大小等。
以下是一个示例输出:
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 158
model name : Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
stepping : 9
microcode : 0x9e
cpu MHz : 2808.000
cache size : 6144 KB
physical id : 0
siblings : 8
core id : 0
cpu cores : 4
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 22
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush d acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcntsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit srbdsbogomips : 5616.00
clflush size : 64
cache_alignment : 64
address sizes : 39 bits physical, 48 bits virtual
power management:
查看内存信息
要查看Linux系统中的内存信息,可以使用以下命令:
cat /proc/meminfo
这个命令将显示有关系统中可用内存、已用内存、缓存等的详细信息。
以下是一个示例输出:
MemTotal: 16384000 kB
MemFree: 12345678 kB
MemAvailable: 13579012 kB
Buffers: 123456 kB
Cached: 1234567 kB
SwapCached: 0 kB
Active: 1234567 kB
Inactive: 1234567 kB
Active(anon): 1234567 kB
Inactive(anon): 1234567 kB
Active(file): 1234567 kB
Inactive(file): 4567 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 1234567 kB
Mapped: 1234567 kB
Shmem: 1234567 kB
Slab: 1234567 kB
SReclaimable: 1234567 kB
SUnreclaim: 1234567 kB
KernelStack: 123456 kB
PageTables: 123456 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 8192000 kB
Committed_AS: 1234567 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
Percpu: 12345 kB
HardwareCorrupted: 0 kB
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 1234567 kB
DirectMap2M: 12345678 kB
DirectMap1G: 1234567 kB
查看硬盘信息
要查看Linux系统中的硬盘信息,可以使用以下命令:
sudo fdisk -l
这个命令将显示有关系统中所有硬盘的详细信息,例如硬盘大小、分区等。
以下是一个示例输出:
Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: ST1000LM035-1RK1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096
Disklabel type: gpt
Disk identifier: 12345678-1234-1234-1234-123456789abc
Device Start End Sectors Size Type
/dev/sda1 2048 1050623 1048576 512M EFI System
/dev/sda2 1050624 500117503 499066880 237.8G Linux filesystem
/dev/sda3 500117504 1953523711 1453406208 693.7G Linux filesystem
示例1
以下是一个示例,演示如何使用lshw
命令查看硬件配置信息:
sudo lshw -short
这个命令将显示系统中所有硬件设备的简短信息。
以下是一个示例输出:
H/W path Device Class Description
==========================================================
system Computer
/0 bus Motherboard
/0/0 memory 64KiB BIOS
/0/4 processor Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
/0/4/5 memory 256KiB L1 cache
/0/4/6 memory 1MiB L2 cache
/0/4/7 memory 6MiB L3 cache
/0/8 memory 16GiB System Memory
/0/8/0 memory 8GiB SODIMM DDR4 Synchronous 2400 MHz (0.4 ns)
/0/8/1 memory 8GiB SODIMM DDR4 Synchronous 2400 MHz (0.4 ns)
/0/100 bridge Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers
/0/100/1 bridge Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (x16)
/0/100/1/0 display GP107M [GeForce GTX 1050 Ti Mobile]
/0/100/2 display Intel Corporation HD Graphics 630
/0/100/14 bus Sunrise Point-H USB 3.0 xHCI Controller
/0/100/14/0 usb1 bus xHCI Host Controller
/0/100/14/0/1 input USB Optical Mouse
/0/100/14/0/2 multimedia USB2.0 HD UVC WebCam
/0/100/14/1 usb2 bus xHCI Host Controller
/0/100/14.2 generic Sunrise Point-H Thermal subsystem
/0/100/16 communication Sunrise Point-H CSME HECI #1
/0/100/17 storage Sunrise Point-H SATA controller [AHCI mode]
/0/100/1c bridge Sunrise Point-H PCI Express Root Port #5
/0/100/1c.5 bridge Sunrise Point-H PCI Express Root Port #6
/0/100/1c.5/0 wlp2s0 network Wireless 8265 / 8275
/0/100/1c.6 bridge Sunrise Point-H PCI Express Root Port #7
/0/100/1c.6/0 enp3s0 network RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
/0/100/1f bridge Intel Corporation HM175 Chipset LPC/eSPI Controller
/0/100/1f.2 memory Memory controller
/0/100/1f.3 multimedia Sunrise Point-H HD Audio
/0/100/1f.4 bus Sunrise Point-H SMBus
/0/100/1f.6 ethernet Ethernet Connection (4) I219-V
/0/1 scsi0 storage
/0/1/0.0.0 /dev/sda disk 1TB ST1000LM035-1RK1
/0/1/0.0.0/1 /dev/sda1 volume 512MiB EFI System partition
/0/1/0.0.0/2 /dev/sda2 volume 238GiB Linux filesystem partition
/0/1/0.0.0/3 /dev/sda3 volume 693GiB Linux filesystem partition
/1 power To Be Filled By O.E.M.
示例2
以下是另一个示例,演示如何使用hwinfo
命令查看硬件配置信息:
sudo hwinfo
这个命令将显示系统中所有硬件设备的详细信息。
以下是一个示例输出:
...
02: PCI 00.0: 0604 PCI bridge (Normal decode)
[Created at pci.386]
Unique ID: _Znp.4Jz+JZBtJZC
SysFS ID: /devices/pci0000:00/0000:00:01.0/0000:01:00.0
SysFS BusID: 0000:01:00.0
Hardware Class: bridge
Model: "NVIDIA Corporation GP107GL [Quadro P1000]"
Vendor: pci 0x10de "NVIDIA Corporation"
Device: pci 0x1cbb "GP107GL [Quadro P1000]"
SubVendor: pci 0x10de "NVIDIA Corporation"
SubDevice: pci 0x11bc
Revision: 0xa1
Driver: "nvidia"
Driver Modules: "nvidia"
Memory Range: 0xd2000000-0xd2ffffff (rw,non-prefetchable)
Memory Range: 0xc0000000-0xcfffffff (ro,non-prefetchable)
Memory Range: 0xd0000000-0xd1ffffff (ro,non-prefetchable)
I/O Ports: 0x3000-0x30ff (rw)
Memory Range: 0xd3000000-0xd307ffff (ro,non-prefetchable)
IRQ: 16 (no events)
Module Alias: "pci:v000010DEd00001CBBsv000010DEsd000011BCbc06sc04i00"
Driver Info #0:
Driver Status: nvidiafb is not active
Driver Activation Cmd: "modprobe nvidiafb"
Driver Info #1:
Driver Status: nouveau is not active
Driver Activation Cmd: "modprobe nouveau"
Driver Info #2:
Driver Status: nvidia_drm is not active
Driver Activation Cmd: "modprobe nvidia_drm"
Driver Info #3:
Driver Status: nvidia is active
Driver Activation Cmd: "modprobe nvidia"
Config Status: cfg=new, avail=yes, need=no, active=unknown
Attached to: #9 (PCI bridge)
...
结束语
在Linux系统中查看硬件配置信息是一项非常重要的任务。通过使用上述命令,您可以轻松地查看CPU、内存和盘等硬件配置信息。