Linux服務(wù)器配置文檔找不到,你還在為查詢Linux服務(wù)器硬件信息發(fā)愁嗎呵扛?學(xué)會(huì)這些命令每庆,讓你輕松查看Linux服務(wù)器的CPU,內(nèi)存今穿,硬盤缤灵,SN序列號(hào)等信息,根本就不用去機(jī)房蓝晒。
一腮出、查看CPU信息
CPU信息常常包括查看CPU型號(hào)信息,物理CPU個(gè)數(shù)芝薇,每個(gè)物理CPU中core的個(gè)數(shù)(即核數(shù))胚嘲,邏輯CPU個(gè)數(shù)信息。默認(rèn)Linux服務(wù)器中洛二,這些信息都保存在/proc/cpuinfo
文件中馋劈,通過cat命令結(jié)合grep命令我們可以很容易查詢出來。
1晾嘶、查看CPU型號(hào)信息
[root@localhost ~]# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
32 Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz
這其中的32
是邏輯CPU的個(gè)數(shù)妓雾,Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz
是CPU型號(hào)信息及頻率。
2垒迂、查看物理CPU個(gè)數(shù)
[root@localhost ~]# cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l
2
上面命令執(zhí)行后械姻,結(jié)果為2
,這就是物理CPU個(gè)數(shù)。
3机断、每個(gè)物理CPU中核數(shù)
[root@localhost ~]# cat /proc/cpuinfo| grep "cpu cores"| uniq
cpu cores : 8
可以從結(jié)果中看出策添,每個(gè)cpu核數(shù)是8
。
4毫缆、查看邏輯CPU的個(gè)數(shù)
[root@localhost ~]# cat /proc/cpuinfo| grep "processor"| wc -l
32
5唯竹、整體查看CPU相關(guān)信息
lscpu
輸出結(jié)果:
[root@localhost ~]# lscpu
Architecture: x86_64 #cpu架構(gòu)
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 32 #邏輯CPU核數(shù)
On-line CPU(s) list: 0-31
Thread(s) per core: 2 #每核超線程數(shù)
Core(s) per socket: 8 #每個(gè)cpu核數(shù)
Socket(s): 2 #物理cpu個(gè)數(shù)
NUMA node(s): 2
Vendor ID: GenuineIntel #cpu產(chǎn)商 intel
CPU family: 6
Model: 62
Model name: Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz
Stepping: 4
CPU MHz: 1200.000 #cpu主頻
BogoMIPS: 5187.29
Virtualization: VT-x #支持cpu虛擬化技術(shù)
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 20480K
NUMA node0 CPU(s): 0-7,16-23
NUMA node1 CPU(s): 8-15,24-31
結(jié)合上面的信息,我們需要了解的CPU的物理數(shù)苦丁,CPU核數(shù)浸颓,物理核數(shù),超線程數(shù)概念關(guān)系如下:
CPU總核數(shù)(16) = 物理CPU個(gè)數(shù)(2) * 每顆物理CPU的核數(shù)(8)
CPU總邏輯數(shù)(32) = 物理CPU個(gè)數(shù)(2) * 每顆物理CPU的核數(shù)(8) * 超線程數(shù)(2)
二、查看內(nèi)存信息
在Linux系統(tǒng)中查看linux內(nèi)存的大小時(shí)产上,我們最長(zhǎng)用到的命令就是free
命令棵磷。free命令可以查看當(dāng)前內(nèi)存大小及使用情況,但如果要查看更多關(guān)于內(nèi)存的物理信息晋涣,例如內(nèi)存條數(shù)仪媒,內(nèi)存插槽數(shù),內(nèi)存速率等信息谢鹊,我們就需要dmidecode
命令算吩。
dmidecode
命令工具用于獲取服務(wù)器的硬件信息,不用到機(jī)房打開機(jī)箱查看設(shè)備型號(hào)佃扼,使用該命令來查找硬件詳細(xì)信息偎巢。
1、查看內(nèi)存使用情況
[root@localhost ~]# free -h
total used free shared buffers cached
Mem: 62G 60G 2.7G 1.2M 483M 56G
-/+ buffers/cache: 3.1G 59G
Swap: 31G 0B 31G
-h
以人類可讀的方式顯示兼耀,即后邊會(huì)自動(dòng)帶上單位压昼。
更多關(guān)于free命令使用,可以查看《如何在Linux系統(tǒng)中使用linux free命令》教程介紹瘤运。
2窍霞、查詢內(nèi)存(RAM)信息
通過以下命令,可以查詢機(jī)器最大支持的內(nèi)存總量**
[root@localhost ~]# dmidecode -t 16
# dmidecode 2.12
SMBIOS 2.7 present.
Handle 0x002B, DMI type 16, 23 bytes
Physical Memory Array
Location: System Board Or Motherboard
Use: System Memory
Error Correction Type: Multi-bit ECC
Maximum Capacity: 768 GB
Error Information Handle: Not Provided
Number Of Devices: 12
這里可以查看到當(dāng)前服務(wù)器允許擴(kuò)容的最大內(nèi)存拯坟,從輸出結(jié)果可以看出但金,該機(jī)器理論上支持的最大內(nèi)存為768G。
3似谁、查看可用內(nèi)存大小
首先我們可以通過cat命令查看/proc/meminfo
文件內(nèi)容獲取內(nèi)存大小信息傲绣。
[root@localhost ~]# grep MemTotal /proc/meminfo
MemTotal: 65890032 kB
4、查看內(nèi)存大小巩踏、內(nèi)存數(shù)秃诵、內(nèi)存插槽數(shù)
[root@localhost ~]# dmidecode|grep -P -A5 "Memory Device" |grep Size
Size: 16384 MB
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: 16384 MB
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: 16384 MB
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: 16384 MB
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
從上面的結(jié)果可以看出,插槽總數(shù)為24塞琼,內(nèi)存數(shù)量為4菠净,總大小為4 x 16384 MB = 65536 MB ,65536 MB /1024 = 64G彪杉。
5毅往、查看內(nèi)存速率
[root@localhost ~]# dmidecode|grep -A16 "Memory Device"|grep 'Speed' | grep -v "Unknown"
Speed: 1600 MHz
Speed: 1600 MHz
Speed: 1600 MHz
Speed: 1600 MHz
從上面的結(jié)果我們們可以看出,所有內(nèi)存的速率都是1600 MHz派近。
三攀唯、查看硬盤信息
查看掛接的分區(qū)狀態(tài)
1、查看掛接的分區(qū)狀態(tài)
[root@localhost ~]# fdisk -l |grep Disk
Disk /dev/sda: 1197.8 GB, 1197759004672 bytes
Disk identifier: 0x0005efcd
2渴丸、查看硬盤和分區(qū)分布
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 1.1T 0 disk
├─sda1 8:1 0 500M 0 part /boot
├─sda2 8:2 0 31.3G 0 part [SWAP]
└─sda3 8:3 0 1.1T 0 part /
sr0 11:0 1 1024M 0 rom
3侯嘀、查看硬盤和分區(qū)的詳細(xì)信息
[root@localhost ~]# fdisk -l
Disk /dev/sda: 1197.8 GB, 1197759004672 bytes
255 heads, 63 sectors/track, 145619 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0005efcd
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 4144 32768000 82 Linux swap / Solaris
/dev/sda3 4144 145620 1136405504 83 Linux
4另凌、查看掛接的分區(qū)狀態(tài)
[root@localhost ~]# mount | column -t
/dev/sda3 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
none on /sys/kernel/config type configfs (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
5、查看硬盤使用情況
[root@localhost ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda3 ext4 1.1T 355G 658G 36% /
tmpfs tmpfs 32G 68K 32G 1% /dev/shm
/dev/sda1 ext4 477M 40M 412M 9% /boot
四戒幔、查看網(wǎng)卡信息
1吠谢、查看網(wǎng)卡硬件信息
[root@localhost ~]# lspci | grep -i 'eth'
02:00.0 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
02:00.1 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
07:00.0 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
07:00.1 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
查看系統(tǒng)的所有網(wǎng)絡(luò)接口
ifconfig -a
ip link show
查看某個(gè)網(wǎng)絡(luò)接口的詳細(xì)信息,例如eth0的詳細(xì)參數(shù)和指標(biāo)
[root@localhost ~]# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: Symmetric
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: Symmetric
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
MDI-X: off (auto)
Supports Wake-on: pumbg
Wake-on: g
Current message level: 0x00000007 (7)
drv probe link
Link detected: yes
六诗茎、其它硬件信息
dmidecode命令不僅僅可以查看內(nèi)存等信息工坊,另外這個(gè)命令強(qiáng)大到幾乎可以查任何硬件信息 包括設(shè)備型號(hào)、bios 敢订、cpu王污、主板 、處理器枢析、內(nèi)存玉掸、緩存詳細(xì)信息等等都例舉出來刃麸。
1醒叁、查看服務(wù)器型號(hào)、序列號(hào)
[root@localhost ~]# dmidecode|grep "System Information" -A9|egrep "Manufacturer|Product|Serial"
Manufacturer: FUJITSU
Product Name: PRIMERGY RX200 S8
Serial Number: MANS012234
2泊业、查看主板型號(hào)
[root@localhost ~]# dmidecode |grep -A16 "System Information$"
System Information
Manufacturer: FUJITSU
Product Name: PRIMERGY RX200 S8
Version: GS01
Serial Number: MANS012234
UUID: 2B5C344E-4406-E411-9EFE-70E284092502
Wake-up Type: Power Switch
SKU Number: S26361-K1455-Vxxx
Family: SERVER
Handle 0x0002, DMI type 2, 15 bytes
Base Board Information
Manufacturer: FUJITSU
Product Name: D3302-A1
Version: S26361-D3302-A100 GS02
Serial Number: 5556W06001G4280004BJ0D1
Asset Tag:
3把沼、查看BIOS信息
[root@localhost ~]# dmidecode -t bios
# dmidecode 2.12
SMBIOS 2.7 present.
Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
Vendor: FUJITSU // American Megatrends Inc.
Version: V4.6.5.4 R1.8.0 for D3302-A1x
Release Date: 06/23/2014
Address: 0xF0000
Runtime Size: 64 kB
ROM Size: 13248 kB
Characteristics:
PCI is supported
BIOS is upgradeable
BIOS shadowing is allowed
Boot from CD is supported
Selectable boot is supported
EDD is supported
Print screen service is supported (int 5h)
Serial services are supported (int 14h)
Printer services are supported (int 17h)
ACPI is supported
USB legacy is supported
BIOS boot specification is supported
Targeted content distribution is supported
UEFI is supported
BIOS Revision: 1.8
Handle 0x0114, DMI type 13, 22 bytes
BIOS Language Information
Language Description Format: Abbreviated
Installable Languages: 1
enUS
Currently Installed Language: enUS
如果要了解更多關(guān)于dmidecode,不妨在命令終端中輸入dmidecode --help
查看該命令的具體使用說明吁伺。
寫在最后
對(duì)于大部分普通Linux用戶來說饮睬,不知道這些命令很正常。但是如果你需要了解一下服務(wù)器信息時(shí)篮奄,這些命令就非常有用了捆愁,不論是維系系統(tǒng)還是核查設(shè)備信息,絕對(duì)是必備技能窟却。
也許你現(xiàn)在不需要昼丑,但你以后可能會(huì)用到,聰明的你不妨先做收藏以備后用夸赫。