Linux ps命令查看进程状态用法(附实例)

Kevin 教程 1,695 次浏览 44条评论

ps是Linux下查询进程状态的内置命令,使用它可以让我们了解程序或事件进程的详细信息。例如CPU/内存用量、运行时间、优先级、所属用户等数据,是Linux新手必要掌握的常用命令之一。下面配合具体实例介绍ps命令的基本用法。若要了解ps完整参数选项,请使用man ps查看手册内容。

列出所有进程

以完整列表方式输出除内核进程外的全部进程信息。

ps -e -f

若进程太多,终端窗口可能显示不全,可以配合more输出,按空格键滚动浏览。

ps -e -f | more

查询用户进程

以长列表方式输出root用户运行的进程,如查询多个用户用逗号隔开。

ps -f -l -u root

查找特定进程

例如查找nginx名称的进程信息。需要留意,-C参数要知道完整进程名称才能找到。

ps -f -C nginx

大部分时候为了方便,可以结合grep用关键词模糊方式查找。

ps -A | grep ngi*

如果已经知道进程ID,则直接用-p参数搜索。多个进程用逗号分隔。

ps -f -p 1373

按进程资源用量排序

按进程所占用的CPU或内存资源来排序,方便定位找出那些最耗资源的进程。

查询CPU使用率前5名的进程。

ps aux --sort=-pcpu | head -n 6

查询内存使用率前5名的进程。

ps aux --sort=-pmem | head -n 6

显示进程父子层级

显示所有进程的层级关系。

ps -e -f --forest

显示指定进程的层级关系。

ps -f --forest -C nginx

显示进程线程状态

查询指定进程中内核线程信息,例如查看123进程的所有线程。

ps -p 123 -L

自定义进程信息列

输出内容可格式化信息列显示,例如只输出用户名、进程ID、资源用量、运行时间和命令列。

ps -e -o uname,pid,pcpu,pmem,etime,comm

评论列表

  1. #1

    making acyclovir more effective https://www.herpessymptomsinmen.org/productacyclovir/

  2. #2

    cost of dapoxetine https://salemeds24.wixsite.com/dapoxetine

  3. #3

    careprost effectiveness over time https://carepro1st.com/

  4. #4

    ivermectin instructions for scabies https://ivermectin.webbfenix.com/

  5. #5

    naltrexone uses https://naltrexoneonline.confrancisyalgomas.com/

  6. #6

    does ivermectin kill scabies eggs https://ivermectin.mlsmalta.com/

  7. #7

    generic vidalista cvs https://vidalista.mlsmalta.com/

  8. #8

    how much is sildenafil http://droga5.net/

  9. #9

    maxim peptide vidalista citrate liquid https://vidalista.buszcentrum.com/

  10. #10

    can cephalexin cause a rash https://keflex.webbfenix.com/

  11. #11

    is generic suhagra as effective as suhagra https://suhagra.buszcentrum.com/

  12. #12

    hydroxychloroquine from mexico https://hydroxychloroquine.mlsmalta.com/

  13. #13

    who owns hydroxychloroquine https://hydroxychloroquine.webbfenix.com/

  14. #14

    atrial fibrillation and taking cialis http://www.lm360.us/

  15. #15

    weight loss after tamoxifen https://tamoxifen.mrdgeography.com/

  16. #16

    how to best use vidalista https://vidalista40mg.mlsmalta.com/

  17. #17

    aurogra contraindications https://aurogra.buszcentrum.com/

  18. #18

    what is ivermectin used for https://ivermectin1st.com/

  19. #19

    cialis cvs https://wisig.org/

  20. #20

    albuterol nebulizer solution for sale https://amstyles.com/

  21. #21

    priligy best https://ddapoxetine.com/

  22. #22

    hydroxychloroquine coronavirus trial results https://sale.azhydroxychloroquine.com/

  23. #23

    hydroxychloroquine 200mg for lupus https://hydroxychloroquinee.com/

  24. #24

    tadalafil 5mg review https://tadalafili.com/

  25. #25

    do africans take hydroxychloroquine https://hydroxychloroquine.lm360.us/

  26. #26

    sildenafil citrate 100mg vs cenforce http://cavalrymenforromney.com/

  27. #27

    buy cialis online without a prescription https://tadalafil.cleckleyfloors.com/

  28. #28

    pet medications online https://medpills.bee-rich.com/

  29. #29

    cialis.com https://cialzi.com/

  30. #30

    sildenafil without a doctor prescription https://sildenafili.com/

  31. #31

    quineprox 80 https://hydroxychloroquine4u.com/

  32. #32

    vidalista without a doctor prescription http://vidallista.com/

  33. #33

    cialis and grapefruit juice reaction https://cialis.cleckleyfloors.com/

  34. #34

    cialis and grapefruit juice reaction https://cialis.advantagetriseal.com/

  35. #35

    Hello! I know this is kind of off topic but I was wondering if you knew where
    I could get a captcha plugin for my comment form?
    I’m using the same blog platform as yours and I’m having
    problems finding one? Thanks a lot! http://antiibioticsland.com/Stromectol.htm

  36. #36

    tadalafil without prescription https://cialis.stdstory.com/

  37. #37

    tadalafil without prescription https://cialis.confrancisyalgomas.com/

  38. #38

    hi!,I like your writing very much! proportion we keep
    in touch more about your article on AOL? I require an expert
    in this house to unravel my problem. Maybe that’s you!
    Taking a look ahead to see you. https://cialis.lm360.us/tadalafil

  39. #39

    Wow, this post is good, my younger sister is analyzing these things, therefore I am going to convey her. https://hydroxychloroquinec.cleckleyfloors.com/

  40. #40

    Hello there I am so excited I found your site,
    I really found you by error, while I was browsing on Digg for something else,
    Anyhow I am here now and would just like to say kudos for a remarkable post and a all
    round enjoyable blog (I also love the theme/design), I don’t have time
    to read through it all at the minute but I have book-marked it and
    also included your RSS feeds, so when I have time I will
    be back to read much more, Please do keep up the excellent b. http://herreramedical.org/cialis

  41. #41

    was hydroxychloroquine ever otc https://hhydroxychloroquine.com/

  42. #42

    Hi every one, here every person is sharing these
    knowledge, so it’s fastidious to read this website, and I used to visit this website everyday. http://antiibioticsland.com/Erythromycin.htm

  43. #43

    Hi mates, fastidious post and pleasant arguments commented here,
    I am really enjoying by these. http://www.deinformedvoters.org/tadalafil-price

  44. #44

    vidalista black 80 mg tablets http://viidalista.co/

发表评论

电邮地址用于 Gravatar 头像显示,不会被公开可见。