Change the sort order using the top command
table of contents
My name is Ito and I am an infrastructure engineer.
The top command is often used when the CPU load is high.
If you look closely, the processes with high CPU will be at the top.
However, in some cases, you may want to order processes other than CPU.
This time, we will show you how to change the sort order using the top command!
Sort type
There are three types of sorting methods that we will introduce here.
shift key + m
shift key + p
shift key + o
use shift key
You can sort by combining the sfift key with "m" or "p".
shift+m | Sort by memory usage |
shift+p | Sort by CPU usage (default) |
It will look like this
・shift+m
・shift+p (default)
even more finely
Of course, there will be other items you want to sort besides memory and CPU.
In such a case, "shift+o" .
The screen will look like this.
On this screen, simply select the alphabet of the item you want to sort and press the Enter key. easy!
By default, the list is sorted by CPU usage, so "K" is selected. (Indicated by an asterisk)
Let's look at each PID.
You'll notice that when you type "a", the PID is selected and the lowercase "a" is changed to an uppercase "A".
Now press Enter. . .
You can now sort by PID!
The ones that are actually often used are RES (q) and Status (w).
bonus
By the way, if you press "f" in the top command, you can add more fields to the screen like shift+o!
I tried to calculate the capacity of SWAP.
top is the first command you use when something happens to the server.
I hope you remember this article when you are concerned about something other than the CPU!