One of the things I had planned when I “restarted” this site was to visit some of the diehard tools — the ones that you probably got for free when you installed your system — and learn to use them better.
The most obvious candidate for that kind of unjustified, overblown disabuse is probably top.
I think most people learn about top very early in their Linux careers. In my case, it no doubt was the first system monitor I learned.
Unfortunately for top, there are so many (so, so many … 😯 ) rival monitors available that it quickly loses its luster.
top is no dullard though. With a little prodding, it actually becomes quite lovely. Let’s get started.
First, we should follow the example of the man page, which says explicitly at the outset … that h is for the help screen, and q is for quit. Remember that, and you’ll never need to panic. 🙂
You might know that pressing the greater-than and lesser-than symbols shift the sort column to the left or right. And you might know to press R to reverse the sort.
But did you know that top is not just black and white? Press z.
Well looky there. A lovely salmon and burgundy theme. Looks like a wine bar on a Friday night.
If you press z again, that color scheme will revert to black and white. Press Z and you get something akin to a theming menu.
You can focus your artistic impulses by selecting the part of the display you want to change, then picking a color. So s followed by 2 will change the summary data to green.
Given time and inclination, you can invent any of a million garish color schemes.
There, that’s awful. Press enter to commit, and return to the main display.
Not as bad as I imagined it. Let’s continue.
top’s summary information can be toggled on or off. Use l, t and m to blink information in and out of view.
Why is that useful at all? Mostly because, as you might realize if you skim through screenshots in obscure forums, the truly geeky always employ some sort of cryptic system status bar grafted to their desktop. One cannot claim geekhood without the cryptic system status bar.
It’s simple enough to fake geekhood though: Pin that abbreviated top in a little terminal in a corner, snap a screenshot and you too can join the ranks of the technophiliacs.
Now let’s really get things screwy. If you press f, you get a list of available fields. Enable or disable a few of those with the space bar, pick a sorting field with s.
Press enter to commit, q to leave that menu, and now your top display is quite unique.
Unique is a good word for that. 🙄
There are quite a few more tricks that we can get top to do. What you see by default is every task listed, whether it’s active or not. Press i to screen out all the idle tasks.
Sorry, I had to dump that awful color scheme. My eyes hurt almost as much as my artistic sensibilities.
Now press V for “forest view,” which is to say, the branched process structure.
Fun. You can also press c for a display of the entire command line used to spawn each process.
Nice. Things are looking much more interesting. Now let’s really crack our knuckles.
If you were paying attention, when we adjusted the color and when we modified the fields, you may have noticed top showing a window title, probably “1:Def”. You can go back and check it now if you don’t believe me.
What we were doing was modifying one of four windows that top can display. Want to see them all at once? Press A.
Four different windows, and if your eyes are sharp, you’ll see that they all display information a little differently.
Number 1 is Def. Two is named Job, 3 is Mem and 4 is Usr. You can probably intuit what each means.
By default we are modifying window 1 … the Default. Color changes, field changes, forest views — whatever, when you change it, you’re probably adjusting default.
How do we get to the other windows? Press g, and you will be asked for your selection.
From there, you can modify any of the other windows you like, with no impact on earlier ones.
What if you don’t want the group? Press hyphen. The group disappears, and the window name in the upper left corner is no longer reversed.
Press hyphen again to bring it back. Press A to return to single-window mode, remembering that your last selected group will now be the focus of your love and attention.
There are a couple of other small things worth trying before bringing this extremely long introduction to a close.
First, if I remember right, top refreshes by default every three seconds. Some of us are impatient and would like to see a quicker display. Press s for adjust the interval.
Careful you don’t overload your Pentium trying to … watch the load. 🙄
top allows you to renice a program — for the uninitiated, that means to adjust its priority in the mix. Press r and you get the chance to emphasize the toys you love, and neglect those you don’t.
Remember that nice values are a little counterintuitive. Take a look at the man pages for top if you’re not sure you’re getting the results you want.
Finally, let’s kill something. The k key in top allows you to send a program into the ether, never to be heard from again.
Confirm it and the target will be terminated … with extreme prejudice.
Note that for those last three commands, when you press the key, the display freezes. That allows you to read a program’s PID if needed, and enter the right target.
Last tip: All that setup and all those configurations are saved when you press the W key. Don’t lose all your hard work. 🙂
I wouldn’t call myself a top expert by any stretch. My hope here was just to show that some of the tools we glance past are just as customizable and interesting as the newcomers.
top does a lot of stuff that most people never know about, because it has a rather droll presentation and doesn’t do some of the things the new kids can.
But take a little time to learn about it and you’ll find all kinds of fun stuff. Where should you go next?
Well, to the man pages, of course. 🙂