Detail Linux How do I view the processes that currently occupy the most CPU or memory

  • 2020-06-07 05:55:29
  • OfStack

The command

ps -aux | sort -k4nr | head -N

Command details:

1. head: -ES7en can specify the number of rows to display. The default display is 10 rows.

2. ps: The parameter a refers to all -- all the processes, u refers to userid -- the user who executes the process, x refers to all the programs, not distinguished by the terminal.

The output format of ps-ES22en is as follows:

root     1 0.0 0.0 19352 1308 ?    Ss  Jul29  0:00 /sbin/init
root     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. In ES27en-k4ES29en (k means sort according to which keyword, the following number 4 means sort according to the fourth column; n refers to numberic sort, sorted by its value; r refers to reverse, here refers to the reverse comparison results, output from small to large by default, reverse from large to small.) . In this example, you can see that %MEM is in position 4, sorted from largest to smallest by the value of %MEM. -k3 means in order of cpu occupancy.

Related articles: