lscpu
是一个在 Linux 系统中用于显示 CPU 架构信息的命令行工具。它可以提供关于处理器、CPU 核心、线程、缓存等方面的详细信息。以下是一些使用 lscpu
命令的技巧:
查看所有 CPU 信息
lscpu
查看特定信息
lscpu | grep 'Architecture'
lscpu | grep 'CPU(s)'
lscpu | grep 'Thread(s) per core'
lscpu | grep 'Cache(s)'
使用 grep
进行过滤:
lscpu | grep 'CPU(s)'
使用 awk
或 cut
进行更复杂的文本处理:
lscpu | awk '/^CPU\(s\):/ {print $2}'
使用 sort
对输出进行排序:
lscpu | sort -k 2,2n
column
命令美化输出:lscpu | column -t
查看详细的 CPU 特性
lscpu -e
查看 CPU 的拓扑结构
lscpu -t
查看 CPU 的详细信息,包括型号和频率
lscpu | grep 'Model name'
lscpu | grep 'MHz'
查看 CPU 的电源管理信息
lscpu | grep 'Power Management'
查看 CPU 的虚拟化支持
lscpu | grep 'Virtualization'
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 158
Stepping: 9
CPU MHz: 2300.000
BogoMIPS: 4600.00
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 8192K
NUMA node0 CPU(s): 0-7
通过这些技巧,你可以更深入地了解你的 Linux 系统中的 CPU 架构和性能特性。