Configuring top in GNU / Linux

Once, a friend of mine, who at that time was administering a certain web application on a server running GNU / Linux, complained about one harmful server administrator. He did not want to install htop in any way, despite all the requests.



I was a little surprised and asked what was the reason for this strange behavior. To simplify, our further dialogue turned out like this:



- He says that the functionality of ordinary top is enough.

- But it’s not enough, do I understand correctly? What functionality is missing in it?

- Well ... He is all gray, I can not see anything on it!



Then I was even more surprised. But it’s no longer the mischief of the server administrator, but the fact that my friend, having decent experience with GNU / Linux, does not know all the features of such a common utility as top .



Yes, of course, if you run top in a freshly created user profile on most distributions, we will see something like this:







Everyone has different eyesight, and I fully admit that in this case, it may be difficult for someone to make out what is interesting. But after all, by pressing just a few keys, the picture changes, for example, to this one:







As you can see, we have as many as four independent windows, with different sets of columns, in each of which the processes are sorted by their parameter. And of course, all this can be configured as you need. And what’s most remarkable - to perform the settings you have enough privileges of an ordinary user.



How to do it?



First, the method is quick (and wrong).

After you got the user session, run top. You will see the default top interface:







But just press β€œ z ”, and the interface will not be so gray:







Already better, but it is not visible, by what parameter the processes are sorted. It doesn’t matter, press β€œ x ” and see:







Even better, but we have one window. Let's do more, press " A ":







There were four windows, but three of them are black and white. Correct the situation. Press β€œ a ” and then β€œ z ”, β€œ x ”.







The processes in the second window are sorted by PID, and we need by% Mem. Fix this by pressing β€œ>” (or β€œ<” if you missed):







Repeat the previous steps for the remaining windows: β€œ a ” to go to the next window, β€œ z ” to enable color display, β€œ x ” to highlight the sort column. Result:







So we got the same result that I demonstrated at the very beginning of the article. Nearly. Attentive readers will immediately point out that I have a different set of fields in the windows, and the colors are different, and the command line for starting the processes is visible in its entirety, and so on. And those who decided to immediately check whether I am writing the truth may be surprised to find that the next time they start, top again turned gray and nondescript.



Of course, it should be so. Therefore, I made a reservation that the method is quick, but wrong.



And now - the right one.



Run top and click " ? ".







Yes, you see the built-in help. It, by the way, is multi-level. But you will be surprised how many users find this screen unique. Because after reading it fluently, we did what they were asked in the last sentence - they pressed β€œ q ” or β€œ Esc ”, which was more convenient for anyone.



And if you read it carefully, you can find out, for example, that after all the necessary settings, you need to press β€œ W ” to save them, and your settings will be saved in the ~ / .toprc file . What colors, a set of fields in each window, display modes of some fields and much more is also customizable.



Small offtopic
In no case do I set as my goal a boring reminder of the benefits of reading documentation. Also, I do not set as my goal a detailed description of all the top settings within the framework of this article, although if readers show interest in this, I will publish the description with pleasure. I do not consider the work of developers of htop and other utilities useless. And of course, I was considering a modern version of top.





I just wanted to say that:





Thanks for your attention.



What else is useful to read on the Cloud4Y blog



β†’ The path of artificial intelligence from a fantastic idea to the scientific industry

β†’ 4 ways to save on backups in the cloud β†’ AI helps to study animals in Africa

β†’ Summer is almost over. Almost no data leaked

β†’ IoT, fog and clouds: talk about technology?



Subscribe to our Telegram channel so as not to miss another article! We write no more than twice a week and only on business.



All Articles