Let's change the sort order using the top command, which is essential for checking CPU load!

My name is Ito and I am an infrastructure engineer

We often use the top command when the CPU load is high.
If you just look at it, the processes with the highest CPU usage will come to the top.

However, in some cases you may want to sort processes by something other than CPU

This time, we will show you how to change the sort order using the top command!

※If you want to review how to use the top command, click here.

To change the sort order

Sorting Type

There are three ways to sort the data:

shift key + m
shift key + p
shift key + o

Use the shift key

You can sort by combining the swift 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_

If you want to sort more precisely

Of course, you may want to sort by other items besides memory and CPU.
In that 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 Enter. Easy!

By default, it is sorted by CPU usage, so "K" is selected (the part with an asterisk).
Now, let's try sorting by PID.

When you type "a", you will see that the PID is selected and the lowercase "a" is changed to an uppercase "A"

a_

Now when you press Enter..

sort-pid_

We were able to sort by PID!
In practice, the most commonly used are RES (q) and Status (w).

bonus

By the way, if you press "f" on the top command, you can add more fields as needed on a screen similar to shift+o!

f

I calculated the SWAP capacity

swap_

The top command is probably the first thing you should use when something happens to your server.
If you're concerned about something other than CPU usage, I hope you remember this article!

If you want to talk to a cloud professional

Since our founding, Beyond has used the technical capabilities we have cultivated as a multi-cloud integrator and managed service provider (MSP) to design, build, and migrate systems using a variety of cloud/server platforms, including AWS, GCP, Azure, and Oracle Cloud

We provide a custom-made cloud/server environment optimized for our customers based on the specifications and functions of the systems and applications they require, so if you are interested in the cloud, please feel free to contact us

● Cloud / Server design and construction
● Cloud / Server migration
● Cloud / Server operation, maintenance and monitoring (24 hours a day, 365 days a year)

If you found this article useful, please click [Like]!
8
Loading...
8 votes, average: 1.00 / 18
76,169
X Facebook Hatena Bookmark pocket

The person who wrote this article

About the author