9个Linux 常用查看系统硬件信息命令(实例详解)
sinye56 2024-12-22 20:40 5 浏览 0 评论
在Linux下,我们经常需要查看系统的硬件信息, 这里我罗列了查看系统硬件信息的实用命令,并做了分类,实例解说。
执行环境:ubuntu 16.04
1. cpu
lscpu命令,查看的是cpu的统计信息.
root@ubuntu:/home/peng/# lscpu
Architecture: x86_64 #cpu架构
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian #小尾序
CPU(s): 1 #总共有1核
On-line CPU(s) list: 0
Thread(s) per core: 1 #每个cpu核,只能支持一个线程,即不支持超线程
Core(s) per socket: 1
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel #cpu产商 intel
CPU family: 6
Model: 158
Model name: Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
Stepping: 9
CPU MHz: 3408.070
BogoMIPS: 6816.14
Hypervisor vendor: VMware
Virtualization type: full #支持cpu虚拟化技术
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 6144K
NUMA node0 CPU(s): 0
查看/proc/cpuinfo,可以知道每个cpu信息,如每个CPU的型号,主频等。
root@ubuntu:/home/peng# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 158
model name : Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
stepping : 9
microcode : 0x48
cpu MHz : 3408.070
cache size : 6144 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 22
wp : yes
.....
2. 内存
概要查看内存情况
root@ubuntu:/home/peng# free -m
total used free shared buff/cache available
Mem: 1970 702 315 13 952 1025
Swap: 974 20 954
这里的单位是MB,总共的内存是1970MB。
查看内存详细使用
root@ubuntu:/home/peng# cat /proc/meminfo
MemTotal: 2017516 kB
MemFree: 242020 kB
MemAvailable: 1003240 kB
Buffers: 104192 kB
Cached: 699824 kB
SwapCached: 1832 kB
Active: 696320 kB
Inactive: 639924 kB
Active(anon): 236412 kB
Inactive(anon): 301996 kB
Active(file): 459908 kB
Inactive(file): 337928 kB
Unevictable: 48 kB
Mlocked: 48 kB
.....
查看内存硬件信息
root@ubuntu:/home/peng# dmidecode -t memory
# dmidecode 3.0
Getting SMBIOS data from sysfs.
SMBIOS 2.7 present.
Handle 0x0084, DMI type 5, 46 bytes
Memory Controller Information
Error Detecting Method: None
Error Correcting Capabilities:
None
Supported Interleave: One-way Interleave
Current Interleave: One-way Interleave
Maximum Memory Module Size: 32768 MB
Maximum Total Memory Size: 491520 MB
Supported Speeds:
70 ns
60 ns
Supported Memory Types:
FPM
EDO
DIMM
SDRAM
Memory Module Voltage: 3.3 V
Associated Memory Slots: 15
.....
内存最大值是 491520 MB。
3. 磁盘
查看硬盘和分区分布
root@ubuntu:/home/peng# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
sda 8:0 0 500G 0 disk
├─sda2 8:2 0 1K 0 part
├─sda5 8:5 0 975M 0 part [SWAP]
└─sda1 8:1 0 499G 0 part /
查看硬盘和分区的详细信息
root@ubuntu:/home/peng# fdisk -l
Disk /dev/sda: 500 GiB, 536870912000 bytes, 1048576000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9c674a44
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 1046575103 1046573056 499G 83 Linux
/dev/sda2 1046577150 1048573951 1996802 975M 5 Extended
/dev/sda5 1046577152 1048573951 1996800 975M 82 Linux swap / Solaris
4. 网卡
查看网卡硬件信息
root@ubuntu:/home/peng# lspci | grep -i 'eth'
02:01.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)
查看系统的所有网络接口
root@ubuntu:/home/peng# ifconfig -a
ens33 Link encap:Ethernet HWaddr 00:0c:29:bb:bd:40
inet addr:192.168.0.117 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::76fa:5548:3da0:2ef/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:174629 errors:0 dropped:0 overruns:0 frame:0
TX packets:105285 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:237519396 (237.5 MB) TX bytes:9592767 (9.5 MB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:854 errors:0 dropped:0 overruns:0 frame:0
TX packets:854 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:60894 (60.8 KB) TX bytes:60894 (60.8 KB)
或者是
root@ubuntu:/home/peng# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 00:0c:29:bb:bd:40 brd ff:ff:ff:ff:ff:ff
或者
如果要查看某个网络接口的详细信息,例如ens33的详细参数和指标
【有的ubuntu网口是eth0】
root@ubuntu:/home/peng# ethtool ens33
Settings for ens33:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full #支持千兆半双工,全双工模式
1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes #默认使用自适应模式
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Speed: 1000Mb/s #网卡的速度是1000Mb
Duplex: Full #全双工
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
MDI-X: off (auto)
Supports Wake-on: d
Wake-on: d
Current message level: 0x00000007 (7)
drv probe link
Link detected: yes #表示有网线连接,和路由是通的
5. pci
查看pci信息,即主板所有硬件槽信息。
root@ubuntu:/home/peng# lspci
00:00.0 Host bridge: Intel Corporation 82845 845 (Brookdale) Chipset Host Bridge (rev 04)
00:01.0 PCI bridge: Intel Corporation 82845 845 (Brookdale) Chipset AGP Bridge(rev 04)
00:1d.0 USB Controller: Intel Corporation 82801CA/CAM USB (Hub #1) (rev 02)
00:1d.1 USB Controller: Intel Corporation 82801CA/CAM USB (Hub #2) (rev 02)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev 42)
00:1f.0 ISA bridge: Intel Corporation 82801CAM ISA Bridge (LPC) (rev 02)
00:1f.1 IDE interface: Intel Corporation 82801CAM IDE U100 (rev 02)
00:1f.3 SMBus: Intel Corporation 82801CA/CAM SMBus Controller (rev 02)
00:1f.5 Multimedia audio controller:Intel Corporation 82801CA/CAM AC'97 Audio Controller (rev 02)
00:1f.6 Modem: Intel Corporation 82801CA/CAM AC'97 Modem Controller (rev 02)
01:00.0 VGA compatible controller: nVidia Corporation NV17 [GeForce4 420 Go](rev a3)
02:00.0 FireWire (IEEE 1394): VIA Technologies, Inc. IEEE 1394 Host Controller(rev 46)
02:01.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+(rev 10)
02:04.0 CardBus bridge: O2 Micro, Inc. OZ6933 Cardbus Controller (rev 01)
02:04.1 CardBus bridge: O2 Micro, Inc. OZ6933 Cardbus Controller (rev 01)
由上述的 输出可以看到,我的电脑上共有3个PCI总线(0号,1号,2号)。在单个系统上,插入多个总线是通过桥(bridge)来完成的,桥是一种用来连接总线 的特殊PCI外设。所以,PCI系统的整体布局组织为树型,我们可以通过上面的lspci输出,来画出我的电脑上的PCI系统的树型结构:
00:00.0(主桥)--00:01.0(PCI桥)-----01:00:0(nVidia显卡)
|
|---00:1d(USB控制器)--00:1d:0(USB1号控制器)
| |
| |--00:1d:1(USB2号控制器) |
|-00:1e:0(PCI桥)--02:00.0(IEEE1394)
| |
| |-02:01.0(8139网卡)
| |
| |-02:04(CardBus桥)-02:04.0(桥1)
| |
| |--02:04.1(桥2)
|
|-00:1f(多功能板卡)-00:1f:0(ISA桥)
|
|--00:1f:1(IDE接口)
|
|--00:1f:3(SMBus)
|
|--00:1f:5(多媒体声音控制器)
|
|--00:1f:6(调制解调器)
由上图可以得出,我的电脑上共有8个PCI设备,其中0号总线上(主桥)上连有4个,1号总线上连有1个,2号总线上连有3个。00:1f是一个连有5个功能的多功能板卡。
如果要更详细的信息:
lspci -v 或者 lspci -vv
如果要看设备树:lscpi -t
root@ubuntu:/home/peng# lspci -t
6. usb
查看usb信息
root@ubuntu:/home/peng# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
lsusb -t查看系统中的USB拓扑,类似cat /sys/kernel/debug/usb/devices
root@ubuntu:/home/peng# lsusb -t
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
|__ Port 1: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 12M
|__ Port 2: Dev 3, If 0, Class=Hub, Driver=hub/7p, 12M
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/6p, 480M
/var/lib/usbutils/usb.ids还保存了很多设备商的VID信息
root@ubuntu:/home/peng# cat /var/lib/usbutils/usb.ids | grep King
7778 Counterfeit flash drive [Kingston]
0100 Kingston Flash Drive (128MB)
c010 Kingston FCR-HS2/ATA Card Reader
07cb Kingmax Technology, Inc.
4100 Kingsun SF-620 Infrared Adapter
4959 Kingsun KS-959 Infrared Adapter
0015 Kingston DataTraveler ELITE
0016 Kingston DataTraveler U3
0998 Kingston Data Traveler2.0 Disk Driver
0999 Kingston Data Traveler2.0 Disk Driver
6519 Kingston DataTraveler 2.0 USB Stick
653c Kingston DataTraveler 2.0 Stick (512M)
653d Kingston DataTraveler 2.0 Stick (1GB)
6544 TransMemory-Mini / Kingston DataTraveler 2.0 Stick (2GB)
6545 Kingston DataTraveler 102/2.0 / HEMA Flash Drive 2 GB / PNY Attache 4GB Stick
0951 Kingston Technology
0d8a King Jim Co., Ltd
00a3 Smart King PRO Uninterruptible Power Supply (HID PDC)
0e56 Kingston Technology Company, Inc.
0f8e Kingnet Technology Co., Ltd
13fe Kingston Technology Company Inc.
1f00 Kingston DataTraveler / Patriot Xporter
1687 Kingmax Digital Inc.
16df King Billion Electronics Co., Ltd.
2149 EntropyKing Random Number Generator
lsusb -v查看系统中USB设备的详细信息
lsusb -v
7. lshw查看所有硬件摘要信息
下面命令可以查看所有硬件摘要信息,并输出成一个html文件,把此html文件导出到电脑上,直接打开,可以清楚的看到硬件信息:
lshw -html > /hardware.html
8. lsscsi查看SCSI控制器设备的信息
可以看到SCSI信息和所有虚拟磁盘以及光驱的信息,如果没有硬件SCSI控制器,那就不会返回信息:
root@ubuntu:/home/peng# lsscsi
[2:0:0:0] disk VMware, VMware Virtual S 1.0 /dev/sda
[4:0:0:0] cd/dvd NECVMWar VMware SATA CD01 1.00 /dev/sr0
插入一个U盘后再查看:
root@ubuntu:/home/peng# lsscsi
[2:0:0:0] disk VMware, VMware Virtual S 1.0 /dev/sda
[4:0:0:0] cd/dvd NECVMWar VMware SATA CD01 1.00 /dev/sr0
[33:0:0:0] disk Kingston DataTraveler G2 1.00 /dev/sdb
可以看到U盘为Kingston。
9. 查看bios信息
root@ubuntu:/home/peng# dmidecode -t bios
# dmidecode 3.0
Getting SMBIOS data from sysfs.
SMBIOS 2.7 present.
Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
Vendor: Phoenix Technologies LTD
Version: 6.00
Release Date: 07/29/2019
Address: 0xEA480
Runtime Size: 88960 bytes
ROM Size: 64 kB
Characteristics:
ISA is supported
PCI is supported
PC Card (PCMCIA) is supported
PNP is supported
APM is supported
BIOS is upgradeable
BIOS shadowing is allowed
ESCD support is available
Boot from CD is supported
Selectable boot is supported
EDD is supported
Print screen service is supported (int 5h)
8042 keyboard services are supported (int 9h)
Serial services are supported (int 14h)
Printer services are supported (int 17h)
CGA/mono video services are supported (int 10h)
ACPI is supported
Smart battery is supported
BIOS boot specification is supported
Function key-initiated network boot is supported
Targeted content distribution is supported
BIOS Revision: 4.6
Firmware Revision: 0.0
dmidecode以一种可读的方式dump出机器的DMI(Desktop Management Interface)信息。这些信息包括了硬件以及BIOS,既可以得到当前的配置,也可以得到系统支持的最大配置,比如说支持的最大内存数等。
如果要查看所有有用的信息
dmidecode -q
里面包含了很多硬件信息。
相关推荐
- 一个不错的软件版本命名规范!
-
之前写了一篇如何自动生成版本号的文章,《让你的C程序,自动打印版本信息》初衷是让自己的程序在运行时自动打印与版本相关的信息,避免测试时因为版本信息不确定导致的一些功能对应不上去的问题,当时留了一个坑,...
- 国产操作系统迎来发展风口 公务领域更能培育起Linux生态
-
谷歌和微软在俄罗斯市场的一番套路猛如虎,就让我们深刻地意识到了,只有自己的东西才能靠得住。也由此,国内操作系统发展迎来了发展风口。我就看到有朋友就秀出了他们单位采购的纯国产的主机,一款华为的主机,纯国...
- 5个大有“前途”的Linux桌面发行版本
-
ZD至顶网CIO与应用频道08月27日专栏:Linux无处不在。你的服务器里,你的电话、汽车、手表、烤面包机、冰箱……和台式机里都有Linux的身影。虽然在桌面上见到Linux的用户比在自动调温...
- Linux 常用应用软件大全
-
编译自:https://www.fossmint.com/most-used-linux-applications/作者:MartinsD.Okoi译者:HankChow对于许多应用程序...
- Linux 4.1 系列的最大版本 4.1.18 LTS发布,带来大量修改
-
(LCTT译注:这是一则过期的消息,但是为了披露更新内容,还是发布出来给大家参考)著名的内核维护者GregKroah-Hartman貌似正在度假中,因为SashaLevin2016年2月16日的...
- Linux发行版需要杀软吗?卡巴斯基推出免费KVRT病毒扫描清理工具
-
IT之家6月4日消息,你认为使用Linux发行版,需要杀毒软件吗?或许很多用户认为Linux发行版偏小众,因此受到黑客攻击的风险也相对较小,不过卡巴斯基并不这么认为,近期推出了适用于...
- 适合开发人员的 5款 Linux 发行版
-
什么是Linux?Linux是基于Unix的操作系统。由LinusTorvalds开发于1991年首次发布其内核。因为Linux是开源软件,其发行版由不同组织发布,因此不同的发行版具有不同的风格...
- VMware Workstation 17.0 Pro 发布:新增 TPM 2.0 完美兼容Win11
-
IT之家11月18日消息,VMwareWorkstation17.0Pro现已发布,它带来了许多新特性,例如微软Windows11硬性要求:虚拟可信平台模块(TPM)2.0。...
- 你是否需要一个容器专用的Linux发行版本?
-
单单使用容器是不够的,提供商们认为你需要一个容器专用的Linux发行版本。我们可以让容器在不同的操作系统上运行,不同的操作系统都有自己的虚拟化服务,如:SolarisZones、BSDJails、...
- Tizen 3.0版本发布 采用Linux 4.1内核
-
2015-09-2111:31:39作者:马荣【中关村在线软件资讯】9月21日消息:尽管三星靠着Android系统设备在移动市场赚钱,但是仍然没有忘记自家的Tizen开发。现在Tizen3.0版...
- 欧拉操作系统演进:应用累计超130万套 支持鲲鹏、英特尔、飞腾等芯片
-
21世纪经济报道记者倪雨晴深圳报道4月15日,在欧拉开发者大会(openEulerDeveloperDay2022)的主论坛上,欧拉首个数字基础设施全场景长周期版openEuler22.03...
- Papyros:以Material Design为灵感的Linux发行版本
-
项目团队并不希望只是采用传统的桌面主题,而是致敬谷歌Android系统的MaterialDesign设计语言想要打造出某些不同以往足够吸引用户的Linux发行版本,自然该版本还在不断的更新和改进中,...
- 比特网早报:全国空间计量技术委员会成立,银河麒麟操作系统上架微信Linux4.0.0版本
-
2024年11月6日消息,昨夜今晨,科技圈都发生了哪些大事?行业大咖抛出了哪些新的观点?比特网为您带来值得关注的科技资讯:全国空间计量技术委员会在北京成立近日,经市场监管总局批准,全国空间计量技术委员...
- 2024年最稳定的5个Linux发行版,赶紧收藏!
-
Linux是最流行的免费开源平台之一。Linux已被广泛使用,因为它安全、可扩展和灵活。Linux发行版收集开源代码,对其进行编译,并将其组合成一个可以轻松启动和安装的操作系统。它们还提供不同的...
- 彰显Linux生态繁华,Ubuntu、Fedora等四发行版同时发布新版本
-
上周对于开源社区来说是忙碌的一周。EndeavourOS和TrueNASScale于周二(4月16日)发布,Fedora于周三(4月17日)发布,Ubuntu于周四(4月18日)发布。四个新版本中都...
你 发表评论:
欢迎- 一周热门
- 最近发表
- 标签列表
-
- oracle忘记用户名密码 (59)
- oracle11gr2安装教程 (55)
- mybatis调用oracle存储过程 (67)
- oracle spool的用法 (57)
- oracle asm 磁盘管理 (67)
- 前端 设计模式 (64)
- 前端面试vue (56)
- linux格式化 (55)
- linux图形界面 (62)
- linux文件压缩 (75)
- Linux设置权限 (53)
- linux服务器配置 (62)
- mysql安装linux (71)
- linux启动命令 (59)
- 查看linux磁盘 (72)
- linux用户组 (74)
- linux多线程 (70)
- linux设备驱动 (53)
- linux自启动 (59)
- linux网络命令 (55)
- linux传文件 (60)
- linux打包文件 (58)
- linux查看数据库 (61)
- linux获取ip (64)
- linux进程通信 (63)