ToB企服应用市场:ToB评测及商务社交产业平台

标题: Linux体系之lscpu下令的基本使用 [打印本页]

作者: 圆咕噜咕噜    时间: 2024-9-1 11:37
标题: Linux体系之lscpu下令的基本使用

一、lscpu下令先容

   lscpu 是一个 Linux 下令,用于表现CPU架构的具体信息。它可以用来查看 CPU 的型号、主频、架构、假造化支持等。
  二、lscpu下令的使用帮助

2.1 下令格式

  1. lscpu [选项]
复制代码
2.2 下令选项


  1. -a, --all               # 打印在线和离线CPU(默认为-e)
  2. -b, --online            # 仅打印在线CPU(-p的默认值)
  3. -c, --offline           # 打印离线CPU
  4. -e, --extended[=<list>] # 打印出一个扩展的可读格式
  5. -p, --parse[=<list>]    # 打印出可解析的格式
  6. -s, --sysroot <dir>     # 将指定的目录用作系统根目录
  7. -x, --hex               # 打印十六进制掩码,而不是CPU列表
  8. -h, --help     # 显示此帮助并退出
  9. -V, --version  # 输出版本信息并退出
复制代码
2.3 使用帮助

   lscpu 下令还支持一些选项和参数,可以通过 lscpu --help 下令来查看具体用法。
  1. [root@jeven ~]# lscpu --help
  2. Usage:
  3. lscpu [options]
  4. Display information about the CPU architecture.
  5. Options:
  6. -a, --all               print both online and offline CPUs (default for -e)
  7. -b, --online            print online CPUs only (default for -p)
  8. -c, --offline           print offline CPUs only
  9. -e, --extended[=<list>] print out an extended readable format
  10. -p, --parse[=<list>]    print out a parsable format
  11. -s, --sysroot <dir>     use specified directory as system root
  12. -x, --hex               print hexadecimal masks rather than lists of CPUs
  13. -y, --physical          print physical instead of logical IDs
  14. -h, --help     display this help and exit
  15. -V, --version  output version information and exit
  16. Available columns:
  17.            CPU  logical CPU number
  18.           CORE  logical core number
  19.         SOCKET  logical socket number
  20.           NODE  logical NUMA node number
  21.           BOOK  logical book number
  22.         DRAWER  logical drawer number
  23.          CACHE  shows how caches are shared between CPUs
  24.   POLARIZATION  CPU dispatching mode on virtual hardware
  25.        ADDRESS  physical address of a CPU
  26.     CONFIGURED  shows if the hypervisor has allocated the CPU
  27.         ONLINE  shows if Linux currently makes use of the CPU
  28.         MAXMHZ  shows the maximum MHz of the CPU
  29.         MINMHZ  shows the minimum MHz of the CPU
  30. For more details see lscpu(1).
复制代码
三、lscpu下令的基本使用

3.1 查看lscpu版本

   使用-V选项,查看lscpu工具版本。
  1. [root@jeven ~]# lscpu -V
  2. lscpu from util-linux 2.23.2
复制代码
3.2 直接使用lspcu下令

   lscpu是一个用于表现和网络有关CPU架构的信息的下令。它可以表现有关CPU型号、焦点数、线程数、缓存大小和架构等信息。打开终端或下令提示符,直接输入lscpu下令并按下回车键
  1. [root@jeven ~]# lscpu
  2. Architecture:          x86_64
  3. CPU op-mode(s):        32-bit, 64-bit
  4. Byte Order:            Little Endian
  5. CPU(s):                6
  6. On-line CPU(s) list:   0-5
  7. Thread(s) per core:    1
  8. Core(s) per socket:    6
  9. Socket(s):             1
  10. NUMA node(s):          1
  11. Vendor ID:             AuthenticAMD
  12. CPU family:            23
  13. Model:                 113
  14. Model name:            AMD Ryzen 5 3600 6-Core Processor
  15. Stepping:              0
  16. CPU MHz:               3593.247
  17. BogoMIPS:              7186.49
  18. Virtualization:        AMD-V
  19. Hypervisor vendor:     VMware
  20. Virtualization type:   full
  21. L1d cache:             32K
  22. L1i cache:             32K
  23. L2 cache:              512K
  24. L3 cache:              32768K
  25. NUMA node0 CPU(s):     0-5
  26. 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 art rep_good nopl tsc_reliable nonstop_tsc extd_apicid eagerfpu pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw perfctr_core retpoline_amd ssbd ibpb vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec clzero arat npt svm_lock nrip_save vmcb_clean flushbyasid decodeassists overflow_recov succor
复制代码
lscpu下令会表现包含以下信息的输出:

3.3 可剖析的格式打印cpu信息

   使用-p选项表现有关CPU拓扑结构的信息,这里列出了每个CPU核的具体信息,包括所属的焦点、插槽、节点以及各级缓存的大小。每一行表示一个CPU核,以逗号分隔的方式列出了对应的ID。
  1. [root@jeven ~]# lscpu -p
  2. # The following is the parsable format, which can be fed to other
  3. # programs. Each different item in every column has an unique ID
  4. # starting from zero.
  5. # CPU,Core,Socket,Node,,L1d,L1i,L2,L3
  6. 0,0,0,0,,0,0,0,0
  7. 1,1,0,0,,1,1,1,0
  8. 2,2,0,0,,2,2,2,0
  9. 3,3,0,0,,3,3,3,0
  10. 4,4,0,0,,4,4,4,0
  11. 5,5,0,0,,5,5,5,0
复制代码
3.4 可扩展格式打印cpu信息

   使用-e选项,使用可扩展格式打印cpu相干信息。
  1. [root@jeven ~]# lscpu -e
  2. CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE
  3. 0   0    0      0    0:0:0:0       yes
  4. 1   0    0      1    1:1:1:0       yes
  5. 2   0    0      2    2:2:2:0       yes
  6. 3   0    0      3    3:3:3:0       yes
  7. 4   0    0      4    4:4:4:0       yes
  8. 5   0    0      5    5:5:5:0       yes
复制代码
四、lscpu下令使用注意事项

   请注意,lscpu下令在差别的利用体系上大概会有一些差异,某些选项大概不可用。可以通过man lscpu下令或lscpu --help下令查看该下令的帮助文档和更多选项。用lscpu下令必要有肯定的Linux体系和硬件知识,并根据实际必要选择合适的选项和下令组合。
  使用lscpu下令必要注意以下几点:


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4