Linux top Command Protips

WARNING: A lot of dated wizardry takes place in this tutorial, if you even want to call it that. It’s partially being posted for me to track my own settings for top, but I would also absolutely love to see more people using top instead of htop. That said, top is extremely powerful, much more so than users give it credit for. I highly recommend becoming more familiar with it, because, in over a decade as a Linux admin, I’ve found top to be my most used tool next to vim.

Welcome to what I like to call “Fearing htop or How I Learned to Love top: Protips for the Linux top Command

Linux admins, get ready to have your socks knocked off.

Open top by typing ‘top‘ and pressing enter.

Nice. I’m proud of you.

Now I want you to type a magic spell that very few wizards know by heart: ‘1tjmPVcxyz‘.

Yes, that’s a true archaic, graybeard Linux admin magic spell from an old dusty tome. Things get even more complicated when you find that some of those options, like ‘t‘ and ‘m‘ have multiple settings you can cycle through.

It’s terrible, I agree, but the good news is you only have to do that once, because ‘W‘ saves your config in a .toprc file. More good news, this rc file is portable. Keep that sucker in the git repo you use for the rest of your rc files and you’ll never have to think of that magic incantation again. Don’t stress over keeping track of whether or not your rc has been copied to Bob, Jane, and root, because you can plop your rc into /etc to make it systemwide. Make sure it’s called topdefaultrc and boom, you’re done.

More good stuff:

Once you’ve fine tuned those different options to look exactly as helpful as it can possibly be to your use case, go ahead and type ‘A‘ to enable advanced mode. Repeat your magical graybeard on each of your new top windows by moving between them with ‘a‘ or ‘w‘. Windows can be collapsed using ‘-‘ or ‘_’ (I remember by thinking of those as different little collapsed or open windows, up and down). Search with ‘L‘ (I think of it as “look”, and that’s really the only thing I feel like you may need to remember here). Finally, arrow keys scroll up, down, left, and right.

That’s a lot. It’s more than a lot. It’s an old scroll that probably, maybe shouldn’t exist any more. The problem is, there are seemingly waaay more powerful features within top that I’m trying to unlock, specifically the ‘Y‘ function. Here’s a bit from tops man:

       Lastly, while `pipe' type entries have been discussed in terms of
       pipelines and commands, there is nothing to prevent you from
       including  shell scripts as well.  Perhaps even newly created
       scripts designed specifically for the `Y' interactive command.

Woah! Sounds intriguing! What the heck does that do, and why do the entries in the man page cause top to through errors when I pipe the exact content into my rc?

If I find out the answer to these questions, I’ll update my post, because this really seems like some insanely intense, crazy powerful Linux magic.

AML

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: