The ps command is a commonly used process management command in the Linux system. You can use this command to view the process information currently running in the system.
ps
The command can sort process information according to different criteria. The common sorting methods are as follows:
- %cpu: Sort according to the proportion of CPU time occupied by processes, use
ps aux --sort=-%cpu
can put the process occupying the most CPU time at the front of the list. - %mem: Sort according to the proportion of memory occupied by the process. Use
ps aux --sort=-%mem
can put the process occupying the most memory at the front of the list. - start: Sort according to the process start time, use
ps aux --sort=-start
to put the process with the latest start time at the front of the list. - pid: Sort according to the process ID, use
ps aux --sort=-pid
to put the process with the largest process ID at the front of the list.
In addition, multiple keywords can also be used for combined sorting. For example, you ps aux --sort=-%cpu,%mem
can sort by CPU usage first, and then sort by memory usage when the CPU usage is the same.
It should be noted that the ps command may have certain differences in different operating systems, and the specific sorting methods and options may also be slightly different. You can use man ps
the command to view specific options and usage.