1. PS command
-aux | sort -k4nr | head -N
* Detailed command:
1. head
:-n can specify the number of rows to display, and 10 rows by default.
2. ps
: Parameter a refers to all processes of all--, u refers to userid--executing the process of the user id,x refers to display all programs, do not differentiate by terminal. The output format of the Ps-aux is as follows:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMANDroot 1 0.0 0.0 19352 1308 ? Ss Jul29 0:00 /sbin/initroot 2 0.0 0.0 0 0 ? S Jul29 0:00 [kthreadd]root 3 0.0 0.0 0 0 ? S Jul29 0:11 [migration/0]
3. SORT-K4NR (k represents the sort from which keyword, followed by the number 4 is sorted according to the fourth column; n refers to numberic sort, according to its numerical order; R refers to the reverse, here refers to the reverse comparison results, the output by default from small to large, backward from large to small. )。 In this example, you can see%mem in the 4th position, based on the value of%mem, from the large to the small sort. -K3 is sorted by CPU utilization.
How Linux looks at the number of processes currently consuming CPU or memory