[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

Change the sort order using the top command

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-m_

・shift+p (default)
shift-p_

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.

k

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".

a_

Now press Enter. . .

sort-pid_

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!

f

I tried to calculate the capacity of SWAP.

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!

If you found this article helpful , please give it a like!
6
Loading...
6 votes, average: 1.00 / 16
66,933
X facebook Hatena Bookmark pocket
[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

The person who wrote this article

About the author