Linux 查看CPU、内存、磁盘的命令

这里是Ubuntu linux系统;

1 查看CPU的命令

输入命令:

top c

显示:

root@iZ2ze0zuq27nx0z96tt9:~# top c
top - 11:23:30 up 9 min,  1 user,  load average: 0.03, 0.04, 0.02
Tasks:  84 total,   1 running,  83 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.7 us,  0.7 sy,  0.0 ni, 98.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :    927.4 total,    245.0 free,    190.1 used,    492.3 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.    594.5 avail Mem 

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                       
      7 root      20   0       0      0      0 I   0.3   0.0   0:00.27 kworker/0:1-events                            
    660 root      10 -10   75568  11720  10284 S   0.3   1.2   0:02.06 AliYunDun                                     
    676 root      10 -10  109788  18324  15792 S   0.3   1.9   0:03.36 AliYunDunMonito                               
      1 root      20   0  102624  12452   8468 S   0.0   1.3   0:01.35 systemd                                       
      2 root      20   0       0      0      0 S   0.0   0.0   0:00.00 kthreadd                                      
      3 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_gp                                        
      4 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_par_gp                                    
      6 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 kworker/0:0H-kblockd                          
      8 root      20   0       0      0      0 I   0.0   0.0   0:00.02 kworker/u4:0-events_power_efficient           
      9 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 mm_percpu_wq                                  
     10 root      20   0       0      0      0 S   0.0   0.0   0:00.05 ksoftirqd/0                                   
     11 root      20   0       0      0      0 I   0.0   0.0   0:00.10 rcu_sched                                     
     12 root      rt   0       0      0      0 S   0.0   0.0   0:00.00 migration/0                                   
     13 root     -51   0       0      0      0 S   0.0   0.0   0:00.00 idle_inject/0                                 
     14 root      20   0       0      0      0 S   0.0   0.0   0:00.00 cpuhp/0                                       
     15 root      20   0       0      0      0 S   0.0   0.0   0:00.00 kdevtmpfs                                     
     16 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 netns                                         
     17 root      20   0       0      0      0 S   0.0   0.0   0:00.00 rcu_tasks_kthre                               
     18 root      20   0       0      0      0 S   0.0   0.0   0:00.00 kauditd                                       
     19 root      20   0       0      0      0 S   0.0   0.0   0:00.00 khungtaskd                                    
     20 root      20   0       0      0      0 S   0.0   0.0   0:00.00 oom_reaper                                    
     21 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 writeback                                     
     22 root      20   0       0      0      0 S   0.0   0.0   0:00.00 kcompactd0                                    
     23 root      25   5       0      0      0 S   0.0   0.0   0:00.00 ksmd                                          
     24 root      39  19       0      0      0 S   0.0   0.0   0:00.00 khugepaged                                    
     70 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 kintegrityd                                   
     71 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 kblockd                                       
     72 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 blkcg_punt_bio                                
     73 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 tpm_dev_wq   

如果想看某个进程PID的使用情况,
输入命令:

top -p 660

其中660为PID。
显示:

root@iZ2ze0zuq27nx0z96tt9:~# top -p 660
top - 11:26:14 up 12 min,  1 user,  load average: 0.00, 0.02, 0.01
Tasks:   1 total,   0 running,   1 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.7 us,  0.3 sy,  0.0 ni, 99.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :    927.4 total,    244.0 free,    191.0 used,    492.3 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.    593.5 avail Mem 

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                       
    660 root      10 -10   75568  11720  10284 S   0.3   1.2   0:02.69 AliYunDun 

2 查看内存的命令

输入命令:

free -m

显示:

root@iZ2ze0zuq27nx0z96tt9:~# free -m
              total        used        free      shared  buff/cache   available
Mem:            927         189         245           2         492         594
Swap:             0           0           0

3 查看磁盘的命令

输入命令:

df -h

显示:

root@iZ2ze0zuq27nx0z96tt9:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            436M     0  436M   0% /dev
tmpfs            93M  700K   93M   1% /run
/dev/vda1        40G   33G  5.2G  87% /
tmpfs           464M     0  464M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           464M     0  464M   0% /sys/fs/cgroup
tmpfs            93M     0   93M   0% /run/user/0

你可能感兴趣的:(Linux,linux,运维,服务器)