Display all processes |
|
|
Use the "u" option or "-f" option to display detailed info |
|
|
Display process by [user] |
|
Show process by name or pid |
To search the processes by their name or command use the "-C" option followed by the search term |
|
To display processes by process id, use the "-p" option and provides the process ids separated by comma |
$ ps -f -p 3150,7298,6544
|
The "-C" must be provided with the exact process name. To search more flexibly, use grep |
|
Sort process by cpu or memory usage |
$ ps aux --sort=-pcpu,+pmem
|
Display the top 5 cpu cosuming processes |
$ ps aux --sort=-pcpu | head -5
|
Display process hierarchy in a tree style |
$ ps -f --forest -C apache2
|
Display child processes of a parent process |
finding all forked apache processes |
$ ps -o pid,uname,comm -C apache2
|
list all child processes |
|
Display threads of a process |
|
Change the columns to display |
The following command shows only the pid, username, cpu, memory and command columns |
$ ps -e -o pid,uname,pcpu,pmem,comm
|
rename the column labels |
$ ps -e -o pid,uname=USERNAME,pcpu=CPU_USAGE,pmem,comm
|