zoukankan      html  css  js  c++  java
  • Linux基础--02--top、free and ps

    top

    可以实时看到占用cpu的情况(每隔5s刷新一次)

    top - 11:42:49 up 3 days, 17:46,  1 user,  load average: 3394.34, 3393.63, 3393.76

    Tasks: 5095 total,   4 running, 5091 sleeping,   0 stopped,   0 zombie

    %Cpu(s):  1.9 us,  4.8 sy,  0.0 ni, 92.8 id,  0.4 wa,  0.0 hi,  0.1 si,  0.0 st

    KiB Mem : 78898592 total,  6672208 free, 71903216 used,   323168 buff/cache

    KiB Swap:        0 total,        0 free,        0 used.  6533600 avail Mem

     

       PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                                        

     25327 root      20   0 2971220 443236  16984 S  10.3  0.6 417:43.74 cm                                                                                                                                                        

    149494 root      20   0  153208   1876   1460 R   5.5  0.0   0:00.17 ps                                                                                                                                                             

    149501 root      20   0   49592   1732   1324 R   5.2  0.0   0:00.16 ps              

     

    free

    linux-37qq:~ # free

                               total       used       free       shared    buffers     cached

    Mem:      16336924    1563160  14773764          0      1836    1242536

    -/+ buffers/cache:    318788  16018136

    Swap:      2103292          0    2103292

     

    16018136=  14773764   +  1836  +   1242536

     

     318788=  1563160-    1836  -  1242536                                                                                                                               

     

    bufferscached,相当于从内存中先拿出来,但不一定完全用完。所以1836表示,取出的buffers但没有用完剩余的,cached同理。

    318788表示实际使用的,所以318788=  1563160-    1836  -  1242536。

    16018136表示所有剩余的。

    ps

    ps aux

    查看所有进程

    linux-37qq:~ # ps aux | grep sbin

    root       421  0.0  0.0  17004   548 ?        S<s   2018   0:00 /sbin/udevd --daemon

    root      1317  0.0  0.0   4004   508 ?        Ss    2018   0:00 /sbin/acpid

    root      1350  0.0  0.0  19308   712 ?        Ss    2018   0:00 /sbin/syslog-ng

    root      1353  0.0  0.0   4272   612 ?        Ss    2018   0:00 /sbin/klogd -c 1 -x

     

    aall

    u:显示用户id

    x:显示在哪个终端

     

    查看进程的头4行:ps aux | head -4

     

    linux-37qq:~ # ps aux | head -4

    USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND

    root         1  0.0  0.0  10540   728 ?        Ss    2018   0:03 init [5] 

    root         2  0.0  0.0      0     0 ?        S     2018   0:00 [kthreadd]

    root         3  0.0  0.0      0     0 ?        S     2018   0:00 [ksoftirqd/0]

     

    grep -v 'grep':去掉本身grep

    linux-37qq:~ #ps aux | grep sbin/min | grep -v 'grep'

    root      3850  0.0  0.0   4496   764 tty1     Ss+   2018   0:00 /sbin/mingetty --noclear tty1

    root      3851  0.0  0.0   4496   764 tty2     Ss+   2018   0:00 /sbin/mingetty tty2

    linux-37qq:~ #ps aux | grep sbin/min

    root      3850  0.0  0.0   4496   764 tty1     Ss+   2018   0:00 /sbin/mingetty --noclear tty1

    root      3851  0.0  0.0   4496   764 tty2     Ss+   2018   0:00 /sbin/mingetty tty2

    root      8246  0.0  0.0   4536   564 pts/0    S+   18:17   0:00 grep sbin/min

     

    kill -9  pid  杀指定进程

    运行firefox程序

    firefox   直接输入后,终端无法再继续输入命令

    firefox$     表示后台运行,不影响当前终端

    jobs查看后台任务

    fg  %1表示将后台任务调到前台来运行  其中1表示jobs中查询的id

    bg  %1 表示将任务调到后台运行

     

    pstree  查看进程树

    pkill-9 进程名     

  • 相关阅读:
    大数据学习13_MapReduce计数器&排序和序列化
    大数据学习12_MapReduce分区
    大数据学习11_MapReduce案例实战(单词统计)
    大数据学习10_Mapreduce
    大数据学习09_HDFS3
    周总结8
    《河北省重大技术需求征集系统》10_导入大量数据做测试
    《河北省重大技术需求征集系统》08_需求浏览
    《河北省重大技术需求征集系统》07_综合查询
    《河北省重大技术需求征集系统》06_网络审核
  • 原文地址:https://www.cnblogs.com/jinf/p/10227098.html
Copyright © 2011-2022 走看看