zoukankan      html  css  js  c++  java
  • 9.ps的示例

    1.查询你拥有的所有进程:

    ps -x

    2.显示指定用户名(RUID)或用户ID的进程:

    ps -fU apache
    ps -fu 48

    3.显示指定用户名(EUID)或用户ID的进程:

    ps -fu wang
    ps -fu 1000

    4.查看以root用户权限(实际和有效ID)运行的每个进程:

    ps -U root -u root

    5.列出某个组拥有的所有进程(实际组ID:RGID或名称):

    ps -fG nginx

    6.列出有效组名称(或会话)所拥有的所有进程:

    ps -fg mysql
    ps -fG 27

    7.通过进程ID来显示所属的进程:

    ps -fp 1234

    8.以父进程ID来显示其下所有的进程,如显示父进程为1154的所有进程:

    ps -f --ppid 1154

    9.显示指定PID的多个进程:

    ps -fp 1204,1239,1263

    10.要按tty显示所属进程:

    ps -ft pts/0

    11.以进程树显示系统中的进程如何相互链接:

    ps -e --forest

    12.以进程树显示指定的进程

    ps f -fC sshd
    ps -f --forest -C sshd
    ps aux|grep sshd|grep -v grep
    ps -ef --forest | grep -v grep | grep sshd

    13.要显示一个进程的所有线程,将显示LWP(轻量级进程)以及NLWP(轻量级进程数)列:

    ps -fL -C nginx

    14.要列出所有格式说明符:

    ps L

    15.查看进程的PID,PPID,用户名和命令:

    ps -eo pid,ppid,user,cmd

    16.自定义格式显示文件系统组,ni值开始时间和进程的时间:

    ps -p 1234 -o pid,ppid,fgroup,ni,lstart,etime

    17.使用其PID查找进程名称:

    ps -p 1244 -o comm=

    18.要以其名称选择特定进程,显示其所有子进程

    ps -C sshd,bash

    19.查找指定进程名所有的所属PID,在编写需要从std输出或文件读取PID的脚本时这个参数很有用:

    ps -C httpd,sshd o pid=
    ps -C httpd,sshd -o pid=

    20.检查一个进程的执行时间

    ps -eo comm,etime,user | grep nginx

    21.查找占用最多内存和CPU的进程:

    ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head(7以上可以)
    ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head(7以上可以)

    22.显示安全信息:

    ps -eM
    ps --context

    23.使用以下命令以用户定义的格式显示安全信息。

    ps -eo euser,ruser,suser,fuser,f,comm,label

    24.使用watch实用程序执行重复的输出以实现对就程进行实时的监视,如下面的命令显示每秒钟的监视:

    watch -n 1 'ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head'(单引号)
  • 相关阅读:
    Palindrome Linked List 解答
    Word Break II 解答
    Array vs Linked List
    Reverse Linked List II 解答
    Calculate Number Of Islands And Lakes 解答
    Sqrt(x) 解答
    Find Median from Data Stream 解答
    Majority Element II 解答
    Binary Search Tree DFS Template
    188. Best Time to Buy and Sell Stock IV
  • 原文地址:https://www.cnblogs.com/lqynkdcwy/p/9571176.html
Copyright © 2011-2022 走看看