Okay, so this is top, the performance dashboard for Linux. When I tell people about top, there's
always people asking me, Hey, standard, have you heard of H top? Yes, of course, I've heard
of H top. And there are other top like utilities as well. The reason I'm showing you top and
nothing else is simple to explain. Top will always be present on your system. Because
top is a standard Linux utility. H top is a fancy version of top, it's showing you colors,
it's showing you much more details. But it also has a much larger system overhead. And
for that reason, you won't find H top by default installed on most systems. You can see it
right here in bold typeface. Top is using a CPU percentage of about 0.3%. I have seen
H top systems that are using about 4% just for H top. And let's face it, you are using
utilities like this. If you have an issue with your performance, then you don't want
to earn a utility. That's a performance hit itself. Also notice that in many cases, it
will not be allowed to install different utilities anyway. Imagine that you're a consultant and
you want to help a customer with their performance problems. And then you are going to tell them,
hey, can you install H top for me? Most likely they are going to tell you no, because installing
unauthorized software is not something that is easily done in many Linux installations. Now
the top interface right here is a little bit boring. I'm using Q to quit. And I'm going to
give us some action using DDIF is dev 0, OF is dev null. And I'm making it background job. And
then I'm running top again, so that at least we have one process that is creating some
action. First thing I would look at in the top interface is the load average. Load average is
giving the total amount of runnable processes over the last 1, 5 and 15 minutes. A runnable
process is a process that is currently active, but also a process that wants to be served. So
if you see six runnable processes, it doesn't mean that these are always active at the same
time, because that is determined by the number of CPUs that you have. One CPU can only have one
process active at any moment in time. So on a four CPU system, if you have a load average of six,
that indicates that you have more processes than your system can handle. And you need to further
investigate what is going on. So for the proper identification of what is going on, it's important
that you know how many CPUs you have. Now here, you can almost guess, look, we have the DD process
causing 100%. And we have my system, the CPUs line, and the parameter I'm looking at is ID for
the idle loop. Idle loop is the amount of time my CPU is doing nothing. So for 50% of its time, my
CPU is doing nothing. That means that this must be a two CPU system. You want to know it for sure,
just press one from the top interface. And there you can see that yes, indeed, this is a two CPU
system. Now CPUs is the next item that I'm interested in. You can see my active CPU is busy
in user and in system space. User and system space are the areas of your operating system, where
system space relates to kernel work, and user space relates to user processes. So here, the usage
is mainly happening in kernel space. That is surprising in most cases, because in most cases,
you will see a higher level of activity in user space. And if you see a high level of activity in
kernel space, that indicates that you have very busy drivers. Now knowing what is going on in my
command, the DD, IF and OF is, I know that I'm going from one driver to another driver. So that does
make sense. The other parameter I'm interested in is ID. ID is the idle loop, the percentage of time
that your system is doing nothing. And I want the idle loop to be as high as possible. The other
parameters are not so interesting. In the past, when disks were still slow, instead of all being SSD,
you would be interested in WA. WA is waiting for IO. And waiting for IO is what you get if your
system is waiting for your disk to process the files. But nowadays, disks are fast enough, and
for that reason, you don't see waiting for IO anymore. Now we have the memory usage. And in the
memory usage, we have this line indicating that we have about four gigabytes in total, of which three
gigabytes is free, and only 530 megabytes is used. And we also have 554 in buffers and cache.
Buffers and cache is an area that your Linux system is using to speed up a little bit. And by keeping
more files in buffers and cache, the next time you read the same file, you can serve it from the cache,
and that will make your system faster. In the end, buffers and cache is not required, and that is why
available memory is showing even more than what you see in free. And that is because your operating
system is considering everything in cache, and it knows if the data in cache is actively being
used or not. And if it's not actively being used, the Linux kernel knows that it can be dropped if
more memory is needed. And in the last column, we can see the actual activity. By default, it's
sort on CPU usage. You can also sort it on other things, and the easy way to do so is by using
greater than or smaller than. Greater than is bringing you to the right, so right now I'm
sorting on memory usage, and smaller than is bringing you to the left. So if I do that a couple of times
right now, it is sorting on virtual memory usage. The virtual memory is not memory that is really in
use. If you want to check memory that is really in use, go for a resident memory. So I'm using my
uppercase arrow to the right once more. Now top is awesome, because apart from this overview,
you can reanalyze and kill processes, and you can also reorganize the top interface.
If you press F, then you get all the fields that you could be seeing in top. And if there is anything
that you would like to see, you just use your arrow key to go over the option that you want to see.
Here I see last used CPU. Well, that's what I want to see, so I'm using spacebar to select it, Q to
get back to top, and look at that. We now have an additional column for the last CPU. And if you want
to write your modifications to a persistent configuration file, use uppercase W. Uppercase W
will write a file with the name toprc to make your setting persistent.
So when I quit and I start top again, I can see my CPU column is listed again.