Linux系统命令
理解Linux系统信息
1.查看Linux服务器的CPU详细情况
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 61
model name : Intel Core Processor (Broadwell)
stepping : 2
microcode : 0x1
cpu MHz : 2194.916
cache size : 4096 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtsse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 hle avx2 sm
bogomips : 4389.83
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
显示物理CPU个数的命令
[root@10-13-92-107 root]# cat /proc/cpuinfo | grep "physical id" |sort |uniq |wc -l
1
查看每个物理CPU中的core的个数(即核数)的命令
[root@10-13-92-107 root]# cat /proc/cpuinfo | grep "cpu cores"|uniq
cpu cores : 1
显示逻辑CPU的个数的命令
[root@10-13-92-107 root]# cat /proc/cpuinfo | grep "processor" |wc -l
1
物理CPU个数*核数 = 逻辑CPU数,如果不相等,那么使用超线程技术
2.查看Linux服务器的内存使用情况
free -m
[root@10-13-92-107 root]# free -m
total used free shared buff/cache available
Mem: 1935 1043 217 104 673 572
Swap: 511 446 65
free命令显示当前内存使用情况,m的意思指的是以M个字节显示内容
3.查看Linux服务器的硬盘使用情况
1)查看硬盘即分区信息
[root@10-13-92-107 root]# fdisk -l
Disk /dev/vda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000ba0a4
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 41943039 20970496 83 Linux
2)检查文件系统的磁盘空间占用情况
[root@10-13-92-107 root]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 20G 16G 4.2G 80% /
devtmpfs 958M 0 958M 0% /dev
tmpfs 968M 0 968M 0% /dev/shm
tmpfs 968M 114M 855M 12% /run
tmpfs 968M 0 968M 0% /sys/fs/cgroup
tmpfs 194M 0 194M 0% /run/user/0
3)查看磁盘的I/O性能
[root@10-13-92-107 root]# iostat -d -x -k 1 10
Linux 3.10.0-957.1.3.el7.x86_64 (10-13-92-107) 06/20/2020 _x86_64_ (1 CPU)
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
vda 0.01 0.07 0.37 1.54 29.16 7.44 38.28 0.02 12.03 57.10 1.27 0.56 0.11
vdb 0.00 0.00 0.00 0.00 0.00 0.00 43.27 0.00 0.45 0.45 0.00 0.31 0.00
%util(一秒中有百分之多少的时间用于I/O操作)接近100%,则说明产生的I/O请求太多,I/O系统已经满负荷,磁盘IO可能存在瓶颈。
await(平均每次设备I/O操作的等待时间(毫秒))。这个响应时间应该低于5ms,如果大于5ms就表示磁盘I/O压力很大,这个时候就可以考虑更换响应速度更快的磁盘等其他方法。
4)查看特定目录的大小
[root@10-13-92-107 /]# du -sh app
2.0G app
##查看目录下前十大小的文件夹或者文件
[root@10-13-92-107 /]# du -cks * |sort -rn |head -n 10
15966900 total
5972200 var
2768564 data
1994864 app
1941460 usr
1802400 op