the Linux PS command lists the processes that are running at the current time. through the PS command we can know the status of the process, memory footprint, start time, and so on.
ps Command section options:
PS Command output column field Description:
Field |
Description |
%cpu |
How many CPUs are being used by a process |
%mem |
How much memory is being used by the process |
ADDR |
Memory address of the process |
C or CP |
CPU Usage and scheduling information |
command* |
Process name, including parameters (if any) |
NI |
Nice value |
F |
Sign |
Pid |
Process ID |
PPID |
Parent Process ID |
Pri |
Process priority |
Rss |
Real Memory usage |
S or STAT |
Process status Code process State is represented by characters, such as R (running is running or ready to run), S (sleeping Sleep), I (Idle idle), Z (Zombie), D (non-disruptive sleep, usually I/O), P (wait for swap page), W (swap out, Indicates that the current page is not in memory), N (Low priority Task) T (terminate terminated), W has no resident pages |
START or Stime |
Process Start time |
VSZ |
Virtual Memory usage |
Time |
Total CPU Usage |
tt or TTY |
Process-related terminals |
UID or user |
User name of the process owner |
Wchan |
The memory address of the event that the process waits for, the kernel function name that the process is sleeping on, and the name of the function is obtained from the/root/system.map file. |
(1) List all running processes
Ps-ef
Ps-aux
(2) List processes based on user or process name or grep
Ps-u MySQL
Ps-c mysqld
Ps-aux | grep MySQL
(3) Sort the process by memory and CPU
PS aux--sort=-pcpu | Head-5 #按cpu占用从大到小排序
PS aux--sort=-pmem | Head-5 #按内存占用从大到小排序
(4) Display process information in a tree structure (via--forest option)
Ps-f--forest-c Chrome