## Or How I Learned To Stop Worrying And Love top

First of all, if you’re running Linux on your laptop and a media server in your house or you’re the admin of a small number of servers that you have complete control over then this article is not aimed at you. You can configure your systems however you want. I won’t judge.

The purpose of this article is to try to explain why becoming dependant on specialised tools is going to make your life harder. By “specialised tools” here I mean packages that are not amongst the default packages on most distros.

The sorts of tools I have in mind are:

‘htop’ and ‘glances’ are great tools. They provide lots of information very clearly and enable debugging an issue much more easily.

The problem and the reason for this article is that in all likelihood they won’t be there when you need them. Sure you could install them. But frequently this is not possible (are they in the repos? Am I allowed to? Is the disk thrashing so much that it would take half an hour? etc etc etc).

## So What Should You Do?

Train yourself to use the tools that you will find on every Linux system AND get used to reading their less pretty output. The following is a short list of the tools that will give (most of) the same information and you will always find on every linux server.

### Process information, load, memory use, CPU usage

The tool here is top. It displays a ton of system metrics but requires a little familiarity to use rapidly. The easiest way to do that is to start using in place of htop or similar tools every day.

top has some interactive commands i.e. that work while it is running. The most useful of these are: - m - pressing m whilst top is running will order the processes by their memory usage (instead of CPU usage) - 1 - pressing 1 will show every CPU core use rather than the system aggregate. Then pressing t will show this info in bar charts. - k - pressing k will allow you to kill a process. The default on pressing k is to select the top process i.e. the one using the most CPU or memory if that is how the processes are ordered.

### Disk Use

The df command will give you information on all the system’s filesystems:

df -h


Alternatively, lsblk will also give the same information but is easier to read and nicely formatted.

If you need to know which directory under the current one is using the most disk space use du piped in sort -h to get the results ordered by size:

du -hs * | sort -h


### System IO

The command vmstat will show the amount of data being read and written to the block devices as well as swap along with CPU usage and IO wait. It is most usefully run as a continuous report. The following gives updates every 5 seconds:

vmstat 5


## Aliases

The other specialised tool which causes the same issues are bash aliases with replace common commands. The most frequent that I have seen is aliasing ll with ls -la --color=auto.

Once you commit ll to muscle memory then the first thing you will see whenever you want a directory listing on a server without the alias set will be:

[~]\$ ll

Then you’re going to have to run ls -la anyway. After you have typed ls -la a few thousand times you will be able to do it almost as rapidly as ll.