13349

67 分钟

#Bash 的 lscpu 命令

lscpu [OPTION]... [DEVICE]...

功能

列出 CPU 信息。

类型

可执行文件(/usr/bin/lscpu),属于 util-linux

参数

  • OPTION 选项:
    • -a, --all - 显示所有 CPU;必须和 --extended--parse 一起使用
    • -B, --bytes - 使用字节作为单位
    • -b, --online - 仅显示在线的 CPU;必须和 --extended--parse 一起使用
    • -C, --caches[=list] - 显示 CPU 缓存信息,可用通过 list 指定输出的列名列表(以逗号分隔)
    • -c, --offline - 仅显示离线的 CPI;必须和 --extended--parse 一起使用
    • --hierarchic[=when] - 在摘要输出中使用子小节
    • -e, --extended[=list] - 以易于理解的格式输出,可用通过 list 指定输出的列名列表(以逗号分隔)
    • -J, --json - 以 JSON 格式输出
    • -p, --parse[=list] - 优化命令输出以便于解析,可用通过 list 指定输出的列名列表(以逗号分隔)
    • -s, --sysroot directory - 指定根目录为 directory,可用于查看来自其它系统的 udev 信息
    • -x, --hex - 使用十六进制掩码表示 CPU 集
    • -y, --physical - 显示所有包含拓扑元素的列的物理 ID
    • --output-all - 显示所有可用的列
    • --help - 显示当前帮助
    • --version - 显示版本
  • DEVICE - 要查看的设备列表,默认为查看所有设备

#列名

#-e-p 选项可用的列名

列名说明
BOGOMIPSCPU 速度的粗略策略
CPU逻辑 CPU 编号
CORE逻辑核心编号
SOCKET逻辑插槽编号
CLUSTER逻辑簇编号
NODE逻辑非一致性内存访问(NUMA)编号
BOOK逻辑书本(包含多个 NUMA)编号
DRAWER逻辑抽屉(包含多个 Book)编号
CACHECPU 之间如何共享缓存
POLARIZATION虚拟硬件上的 CPU 调度模式
ADDRESSCPU 的物理地址
CONFIGURED虚拟机管理程序(Hypervisor)是否已经分配 CPU
ONLINELinux 当前是否使用 CPU
MHZCPU 当前频率(MHz)
SCALMHZ%CPU 频率缩放百分比
MAXMHZCPU 最高频率(MHz)
MINMHZCPU 最低频率(MHz)
MODELNAMECPU 型号名称

#-C 选项可用的列名

列名说明
ALL-SIZE所有系统缓存的大小
LEVEL缓存级别
NAME缓存名称
ONE-SIZE一个缓存的大小
TYPE缓存类型
WAYS缓存的关联
ALLOC-POLICY缓存的分配策略
WRITE-POLICY缓存的写策略
PHY-LINE每个缓存标配对应的对应的物理缓存行数
SETS缓存中集合的数量
COHERENCY-SIZE从内存传输到缓存的最小数据量

#示例

$ lscpu
Architecture:             x86_64
  CPU op-mode(s):         32-bit, 64-bit
  Address sizes:          43 bits physical, 48 bits virtual
  Byte Order:             Little Endian
CPU(s):                   8
  On-line CPU(s) list:    0-7
Vendor ID:                AuthenticAMD
  Model name:             AMD Ryzen 5 3400G with Radeon Vega Graphics
    CPU family:           23
    Model:                24
    Thread(s) per core:   2
    Core(s) per socket:   4
    Socket(s):            1
    Stepping:             1
    Frequency boost:      enabled
    CPU(s) scaling MHz:   36%
    CPU max MHz:          3700.0000
    CPU min MHz:          1400.0000
    BogoMIPS:             7385.99
    Flags:                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid a
                          perfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw skinit wdt tce t
                          opoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb hw_pstate ssbd ibpb vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 clzero irperf xsaveerptr arat
                           npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif overflow_recov succor smca sev sev_es ibpb_exit_to_user
Virtualization features:
  Virtualization:         AMD-V
Caches (sum of all):
  L1d:                    128 KiB (4 instances)
  L1i:                    256 KiB (4 instances)
  L2:                     2 MiB (4 instances)
  L3:                     4 MiB (1 instance)
NUMA:
  NUMA node(s):           1
  NUMA node0 CPU(s):      0-7
Vulnerabilities:
  Gather data sampling:   Not affected
  Itlb multihit:          Not affected
  L1tf:                   Not affected
  Mds:                    Not affected
  Meltdown:               Not affected
  Mmio stale data:        Not affected
  Reg file data sampling: Not affected
  Retbleed:               Mitigation; untrained return thunk; SMT vulnerable
  Spec rstack overflow:   Mitigation; Safe RET
  Spec store bypass:      Mitigation; Speculative Store Bypass disabled via prctl
  Spectre v1:             Mitigation; usercopy/swapgs barriers and __user pointer sanitization
  Spectre v2:             Mitigation; Retpolines; IBPB conditional; STIBP disabled; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
  Srbds:                  Not affected
  Tsx async abort:        Not affected

#推荐阅读

#手册

更新: 2026/2/5

作者: PlanC

创建: 2026/2/4