几个常用的ps命令

时间:2023-03-09 04:31:54
几个常用的ps命令

1. ps aux

If you are looking for a short summary of the active processes, use  ps aux

[root@rhel7 tmp]# ps aux |head
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 0.0 0.3 ? Ss Jun27 : /usr/lib/systemd/systemd --switched-root --system --deserialize
root 0.0 0.0 ? S Jun27 : [kthreadd]
root 0.0 0.0 ? S Jun27 : [ksoftirqd/]
root 0.0 0.0 ? S Jun27 : [migration/]
root 0.0 0.0 ? S Jun27 : [rcu_bh]
root 0.0 0.0 ? S Jun27 : [rcuob/]
root 0.0 0.0 ? R Jun27 : [rcu_sched]
root 0.0 0.0 ? S Jun27 : [rcuos/]
root 0.0 0.0 ? S Jun27 : [watchdog/]

2. ps -ef 

If you are not only looking for the name of the process but also for the exact command that was used to start the process, use ps -ef .

[root@rhel7 tmp]# ps -ef |head
UID PID PPID C STIME TTY TIME CMD
root Jun27 ? :: /usr/lib/systemd/systemd --switched-root --system --deserialize
root Jun27 ? :: [kthreadd]
root Jun27 ? :: [ksoftirqd/]
root Jun27 ? :: [migration/]
root Jun27 ? :: [rcu_bh]
root Jun27 ? :: [rcuob/]
root Jun27 ? :: [rcu_sched]
root Jun27 ? :: [rcuos/]
root Jun27 ? :: [watchdog/]

3.ps fax

which shows hierarchical relationships between parent and child processes.

[root@rhel7 tmp]# ps fax | head
PID TTY STAT TIME COMMAND
? S : [kthreadd]
? S : \_ [ksoftirqd/]
? S : \_ [migration/]
? S : \_ [rcu_bh]
? S : \_ [rcuob/]
? R : \_ [rcu_sched]
? S : \_ [rcuos/]
? S : \_ [watchdog/]
? S< : \_ [khelper]