如何查看linux服务器的cpu数量,内核数,和cpu线程数?

lscpu命令检查cpu统计信息。
\x0d\x0ablue@blue-pc:~$lscpu\x0d\x0aArchitecture:i686#cpuArchitecture\x0d\x0aCPUop-mode(s):32-bit,64-bit\x0d\x0aByteOrder:LittleEndian#littleendian\x0d\x0aCPU(s):4#一共有4个core\x0d\x0a在线CPU列表:0-3\x0d\x0aThread(s)percore:1#每个cpu核心只能支持1个线程,即不支持超线程\x0d\x0aCore(s)pe​​rsocket:4#每个cpu有4个核心\x0d\x0aSocket(s):1#总共有1个cpu\x0d\x0a供应商ID:正版英特尔#cpuManufacturingrintel\x0d\x0aCPU系列:6\x0d\x0a型号:42\x0d\x0a步进:7\x0d\x0aCPUMHz:1600.000\x0d\x0aBogoMIPS:5986.12\x0d\x0aVirtualizaVT-x#支持cpu虚拟化技术\x0d\x0aL1dcache:32K\x0d\x0aL1icache:32K\x0d\x0aL2cache:256K\x0d\x0aL3cache:6144K\x0d\x0a\x0d\x0a查看/proc/cpuinfo,即可知道每个CPU的信息,没有比如每个CPU的型号和主频。
\x0d\x0a#cat/proc/cpuinfo\x0d\x0a处理器:0\x0d\x0avendor_id:GenuineIntel\x0d\x0acpufamily:6\x0d\x0amodel:42\x0d\x0amodelname:Intel(R)Core(TM)i5-2320CPU@3.00GHz\x0d\x0a....\x0d\x0a上面输出的是第一个cpu部分信息,有3个cpu信息skip。
\x0d\x0a\x0d\x0a内存\x0d\x0a概览查看内存状态\x0d\x0afree-m\x0d\x0atotalusedfreesharedbufferscached\x0d\x0aMem:39263651274012404\x0d\x0a-/+buffers/cache:3235691\x0d\x0aSwap:9536319505\x0d\x0a这里的单位是MB,总内存是3926MB。
\x0d\x0a\x0d\x0a查看详细内存使用情况\x0d\x0a#cat/proc/meminfo\x0d\x0aMemTotal:4020868kB\x0d\x0aMemFree:230884kB\x0d\x0aSetbuffer:7600kB\x0d\x0aCached:454772kB\x0d\x0aSwapCached:836kB\x0d\x0a.....\x0d\x0a\x0d\x0a查看硬件信息记住\x0d\x0admidecode-tmemory\x0d\x0a#dmidecode2.11\x0d\x0aSMBIOS2.7current.\x0d\x0aHandle0x0008,DMItype16,23bytes\x0d\x0aPhysicalMemoryArray\x0d\x0a位置:系统板或主板\x0d\x0a....\x0d\x0a最大容量:32GB\x0d\x0a....\x0d\x0aHandle0x000A,DMItype17,34bytes\x0d\x0a....\x0d\x0aMemoryDe​​vice\x0d\x0aArrayHandle:0x0008\x0d\x0aErrorInformationHandle:NotProvided\x0d\x0aTotalWidth:64bits\x0d\x0aDataWidth:64bits\x0d\x0aSize:4096MB\x0d\x0a....\x0d\x0a我的主板有4个插槽,只有1个插槽使用并设置请记住,此处安装了4096MB。
\x0d\x0a\x0d\x0aDisk\x0d\x0a查看硬盘及分区分布\x0d\x0a#lsblk\x0d\x0aNAMEMAJ:MINRSIZEROTYPEMOUNTPOINT\x0d\x0asda8:00465.8G0disk\x0d\x0a├—sda18:101G0part/boot\x0d\x0a├—sda28:209.3G0part[SWAP]\x0d\x0a├—sda38:3074.5G0part/\x0d\x0a├—sda48:401K0part\x0d\x0a├—sda58:50111.8G0part/home\x0d\x0a└—sda68:60269.2G0part\x0d\x0a显示很直观\x0d\x0a\x0d\x0a如果你想看详细有关硬盘的信息和分区\x0d\x0a#fdisk-l\x0d\x0aDisk/dev/sda:500.1GB,500107862016bytes\x0d\x0a255heads,63sectors/track,60801xilinen,total976773168sector\x0d\x0aUnits=sectorsof1*512=512byte\x0d\x0aSectorsize(逻辑/物理):512bytes/4096bytes\x0d\x0aI/Osize(最小/最佳):4096bytes/4096bytes\x0d\x0a磁盘标识符:0x00023728\x0d\x0aDeviceBootStartEndBlocksIdSystem\x0d\x0a/dev/sda1*20482148351107315283Linux\x0d\x0a/dev/sda2214835221680127976588882Linuxswap/Solaris\x0d\x0a/dev/sda3216801281779302397812505683Linux\x0d\x0a/dev/sda41779322869767710713994193935扩展/dev/sda517793228841230540711718656083Linux\x0d\x0a/dev/sda641230745697677107128223180883Linux\x0d\x0a\x0d\x0a网卡\x0d\x0a查看网卡硬件信息\x0d\x0a#lspci|grep-i'eth'\x0d\x0a02:00.0以太网络控制器:RealtekSemiconductorCo.,Ltd.RTL8111/8168BPCIExpressGigabitEthernetcontroller(rev06)\x0d\x0a\x0d\x0a查看所有系统网络接口\x0d\x0a#ifconfig-a\x0d\x0aeth0Linkencap:硬件地址以太网b8:97:5a:17:b3:8f\x0d\x0a....\x0d\x0aloLinkencap:本地环回\x0d\x0a....\x0d\x0a或\x0d\x0aiplinkshow\x0d\x0a1:lo:mtu16436qdiscnoqueuestateDOWN\x0d\x0al鱿鱼/环回00:00:00:00:00:00brd00:00:00:00:00:00\x0d\x0a2:eth0:mtu1500qdiscpfifo_faststateUPqlen1000\x0d\x0alink/etherb8:97:5a:17:b3:8fbrdff:ff:ff:ff:ff:ff\x0d\x0a\x0d\x0a如果想查看网络接口的详细信息,如参数和eth0的详细指示\x0d\x0a#ethtooleth0\x0d\x0aSettingsforth0:\x0d\x0a端口support:[TPMII]\x0d\x0a支持的链路模式:10baseT/Half10baseT/Full\x0d\x0a100baseT/Half100baseT/Full\x0d\x0a1000baseT/Half1000baseT/Full#支持半双工、全双工模式全千兆\x0d\x0a临时支持stopuseframe:No\x0d\x0a支持自动协商:Yes#支持自适应模式,一般支持\x0d\x0a广告链路模式report:10baseT/Half10baseT/Full\x0d\x0a100baseT/Half100baseT/Full\x0d\x0a1000baseT/Half1000baseT/Full\x0d\x0aAdvertishedpauseframeuse:SymmetricReceive-only\x0d\x0aAdvertishedauto-negotiation:Yes#默认使用自适应模式Definition\x0d\x0aLinkpartneradvertishedlinkmodes:10baseT/Half10baseT/Full\x0d\x0a100baseT/Half100baseT/Full\x0d\x0a....\x0d\x0aSpeed:100Mb/s#网卡当前速度为100Mb,网卡使用使用自适应模式,路由推断为100Mb,导致网卡支持千兆而不是支持100M\x0d\x0aDuplex:Full#全双工\x0d\x0a。
....\x0d\x0aLinkdetector:yes#表示有网线连接,已连接到路由器\x0d\x0a\x0d\x0a其他\x0d\x0a查看pci信息,即主板上硬件插槽的所有信息。
\x0d\x0alspci\x0d\x0a00:00.0Hostbridge:IntelCorporation2ndGenerationCoreProcessorFamilyDRAMController(rev09)#主板芯片\x0d\x0a00:02.0VGA兼容控制器:IntelCorporation2ndGenerationCoreProcessorFamilyIntegratedGraphicsController(rev09)#显卡\x0d\x0a00:14.0USBcontroller:IntelCorporationPantherPointUSBxHCIHostController(rev04)#usbController\x0d\x0a00:16.0传输控制器通信:IntelCorporationPantherPointMEIController#1(rev04)\x0d\x0a00:1a.0USBcontroller:IntelCorporationPantherPointUSBEnhancedHostController#2(rev04)\x0d\x0a00:1b.0音频设备:IntelCorporationPantherPointHighDefinitionAudioController(rev04)#Sound卡\x0d\x0a00:1c.0PCIbridge:IntelCorporationPantherPointPCIExpressRootPort1(revc4)#pci插槽\x0d\x0a00:1c.2PCIbridge:IntelCorporationPantherPointPCIExpressRootPort3(revc4)\x0d\x0a00:1c.3PCIbridge:IntelCorporationPantherPointPCIExpressRootPort4(revc4)\x0d\x0a00:1d.0USBcontroller:IntelCorporationPantherPointUSBEnhancedHostController#1(rev04)\x0d\x0a00:1f.0ISAbridge:IntelCorporationPantherPointLPCController(rev04)\x0d\x0a00:1f.2IDE接口:IntelCorporationPantherPoint4portSATAController[IDEmode](rev04)#硬盘接口\x0d\x0a00:1f.3SMBus:IntelCorporationPantherPointSMBusController(rev04)\x0d\x0a00:1f.5IDE接口:IntelCorporationPantherPoint2portSATAController[IDEmode](rev04)#硬盘接口\x0d\x0a02:00.0以太网控制器:RealtekSemiconductorCo.,Ltd.RTL8111/8168BPCIExpressGigabitEthernetcontroller(rev06)#网络卡\x0d\x0a03:00.0PCIbridge:IntegratedTechnologyExpress,Inc.Device8893(rev41)\x0d\x0a如如果您想要更详细的信息:lspci-v或lspci-vv\x0d\x0a如果您想查看设备树:lscpi-t\x0d\x0a\x0d\x0a查看信息BIOS\x0d\x0a#dmidecode-tbios\x0d\x0a......\x0d\x0aBIOSInformation\x0d\x0a供应商:AmericanMegatrendsInc.\x0d\x0a版本:4.6.5\x0d\x0a发布日期:25/04/2012\x0d\x0a......\x0d\x0aBIOSRevision:4.6\x0d\x0a......\x0d\x0admidecode结果以可读的方式导出机器的DMI(桌面管理接口)信息。
这些信息包括硬件和BIOS,不仅可以获取当前配置,还可以获取系统支持的最大配置,例如支持的最大内存量等。
\x0d\x0a如果想查看所有有用的信息\x0d\x0admidecode-q\x0d\x0a以上是Linux中查看硬件信息的所有命令。
可以查看CPU、硬盘、网卡、磁盘等硬件信息。

linux下查看线程数的几种方法

1、cat/proc/${pid}/status2、pstree-p${pid}3、top-p${pid}然后按H或者直接top-bH-d3-p${pid}top-H回车。
手册上写着:-H:Threadstoggle添加此选项从顶部开始,第一行显示一个线程。
否则,它会在一行中显示一个进程。
4.psxH指令表示:HShowthreadsasiftheywereprocesses可以看到所有现有线程。
5.ps-mp指令表示:mShowthreadsafterprocesses可以检查进程启动的线程数。