1. CPU
- lscpu :
一般不加參數,直接使用該指令.
- cat /proc/cpuinfo:
該檔案中列出了CPU的詳細資訊,類似于'lscpu'指令
lscpu
[niesh @niesh Desktop]$ lscpu
Architecture: x86_64 #CPU的架構(64bit)
CPU op-mode(s): 32-bit, 64-bit #支援32-bit和64-bit
Byte Order: Little Endian #小端(x86架構皆為小端模式)
CPU(s): 1 #總共1個CPU
On-line CPU(s) list: 0
Thread(s) per core: 1 #每個cpu核心,隻能運作一個線程
Core(s) per socket: 1 #隻有一個核心(因為我在虛拟機裡)
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel #Intel生産
CPU family: 6
Model: 142
Model name: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
Stepping: 9
CPU MHz: 2712.002 #CPU的頻率(2712/1024 ~~ 2.5G)
BogoMIPS: 5424.00
Hypervisor vendor: VMware
Virtualization type: full
L1d cache: 32K #L1 cache for data
L1i cache: 32K #L1 cache for instruction
L2 cache: 256K
L3 cache: 3072K
NUMA node0 CPU(s): 0
/proc/cpuinfo
[niesh @niesh ~]$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 142
model name : Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
stepping : 9
microcode : 0x4e
cpu MHz : 2712.002
cache size : 3072 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 22
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ida arat epb pln pts dtherm hwp hwp_noitfy hwp_act_window hwp_epp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid rdseed adx smap xsaveopt
bogomips : 5424.00
clflush size : 64
cache_alignment : 64
address sizes : 42 bits physical, 48 bits virtual
power management:
2. 記憶體
檢視記憶體的指令有多種,如下:
- free: //檢視記憶體大小
-b: 以byte形式顯示
-k: 以KB形式顯示
-m: 以MB形式顯示
-g: 以GB形式顯示
-h: 以友善人類觀察的形式顯示
- cat /proc/meminfo: //記憶體的詳細硬體資訊
- vmstat [sec/time][times] : //類似
, 檢視整個機器CPU、MEM、IO使用情況
top
sec/times: 多少秒重新整理一次
times: 重新整理多少次,不寫則表示持續
- dmidecode -t memeory:
顯示memory的詳細硬體資訊
free:
[niesh@niesh ~]$ free -h
total used free shared buff/cache available
Mem: 1.4G 602M 427M 10M 452M 664M
Swap: 2.0G 0B 2.0G
PS:
buf為緩沖,指用于“寫入”的一塊記憶體
cache為緩存,指用于“讀取”的一塊記憶體
cat /proc/meminfo:
[niesh@niesh ~]$ cat /proc/meminfo
MemTotal: 1517428 kB
MemFree: 437744 kB
MemAvailable: 680592 kB
Buffers: 1260 kB
Cached: 328404 kB
SwapCached: 0 kB
Active: 570780 kB
Inactive: 254344 kB
SwapTotal: 2097148 kB
SwapFree: 2097148 kB
...
vmstat:
[niesh@niesh ~]$ vmstat 3 3 ##3秒每次,總共3次
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 0 437612 1260 461948 0 0 21 2 55 135 0 1 99 0 0
0 0 0 437612 1260 461948 0 0 0 0 34 59 0 0 100 0 0
0 0 0 437612 1260 461948 0 0 0 0 32 51 0 0 100 0 0
以上各列解釋如下:
r: Running, 正在運作和等待運作的程序數
b: Sleeping,處于Sleeeping狀态的程序數
swpd: 虛拟記憶體使用量,一般為0,否則可能是實體記憶體不夠用了
free: 實體記憶體空閑大小
buf: 緩沖區大小
cache: 緩存大小
si: 每秒從虛拟記憶體寫入硬碟的大小
so: 每秒從硬碟讀入到虛拟記憶體的大小
bi: 塊裝置每秒接受的塊數量
bo: 塊裝置每秒發送的塊數量
in: interrupt, 每秒中斷CPU的次數
cs: context switch,每秒切換上下文的次數
us: 使用者CPU時間,%
sy: 系統CPU時間
id: 空閑CPU時間
wa: 等待IO的CPU時間
3. 磁盤
- fdisk -l:
檢視磁盤分區, 此指令必須root執行
- df -h:
列出磁盤的總大小和使用情況
- du -h:
使用該指令,我們可以檢視硬碟的使用情況,但是它會列出所有目錄的大小;該指令的常用用法一般為統計一個目錄的大小:
fdisk -l
[root@niesh ~]# fdisk -l
磁盤 /dev/sda:21.5 GB, 21474836480 位元組,41943040 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/實體):512 位元組 / 512 位元組
I/O 大小(最小/最佳):512 位元組 / 512 位元組
磁盤标簽類型:dos
磁盤辨別符:0x00071326
裝置 Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 41943039 20458496 8e Linux LVM
磁盤 /dev/mapper/centos_niesh-root:18.8 GB, 18756927488 位元組,36634624 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/實體):512 位元組 / 512 位元組
I/O 大小(最小/最佳):512 位元組 / 512 位元組
磁盤 /dev/mapper/centos_niesh-swap:2147 MB, 2147483648 位元組,4194304 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/實體):512 位元組 / 512 位元組
I/O 大小(最小/最佳):512 位元組 / 512 位元組
以上我們可以看到
/dev/sda1
字樣,那它代表什麼意思呢?
我們知道,磁盤我們最常用的接口形式有兩種:
IDE
&
SATA
,不同的接口形式,Linux的顯示是不一樣的:
- IDE
盤符:hd[a-z][1-n]EX: hdb2代表第二塊磁盤的第二個分區hd:代表IDE接口
a-z:硬碟數量排序(a代表第一塊,b第二塊,以此類推)
0-n: 代表第幾個分區
- SATA
盤符:sd[a-z][1-n]
解析同上
注意:分區部分,若為1-4則表示主分區(包含擴充分區),>=5表示邏輯分區
df -h
[root@niesh ~]# df -h
檔案系統 容量 已用 可用 已用% 挂載點
/dev/mapper/centos_niesh-root 18G 9.1G 8.5G 52% /
devtmpfs 726M 0 726M 0% /dev
tmpfs 741M 156K 741M 1% /dev/shm
tmpfs 741M 9.1M 732M 2% /run
tmpfs 741M 0 741M 0% /sys/fs/cgroup
/dev/sda1 497M 158M 339M 32% /boot
.host:/ 222G 17G 206G 8% /mnt/hgfs
tmpfs 149M 20K 149M 1% /run/user/1000
一般我們隻關心
/
/boot
挂載點的大小;
du -h
[root@niesh ~]# du -sh /root
40M /root
[root@niesh ~]# du -sh /dev
156K /dev
[root@niesh ~]# du -sh /etc
36M /etc
4. ip位址資訊:
- ifconfig -a:
檢視本機所有的網絡接口資訊和ip位址資訊
[root@niesh ~]# ifconfig -a
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.139.129 netmask 255.255.255.0 broadcast 192.168.139.255
inet6 fe80::20c:29ff:feb5:18f9 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:b5:18:f9 txqueuelen 1000 (Ethernet)
RX packets 11758 bytes 779308 (761.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 5065 bytes 635337 (620.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 12 bytes 732 (732.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12 bytes 732 (732.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 00:00:00:00:00:00 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
如上所示,我這裡包含了三個網絡接口:
- eno167777736:
CentOS 7.x 的命名規則,其實就相當于eth0
- lo:
loop,回環網絡裝置,ip位址固定為,一般
127.0.0.1
綁定到此端口,隻要本機的網絡組建沒問題,便可以ping通;否則,你就要好好檢查一下自己的網絡硬體了!
localhost
- birbr0:
虛拟機的網絡接口,不做詳細介紹!
5. 其它
以下幾個指令非常強大,可以檢視幾乎所有的硬體資訊:
- dmesg:
詳細資訊參見:http://blog.csdn.net/rwdxll/article/details/38560137
- lspci:
詳細資訊參考:http://blog.csdn.net/styshoo/article/details/51281437
- dmidecode:
詳細資訊請參考:http://www.laozuo.org/6682.html