1 00:00:06,599 --> 00:00:09,589 A command that I really like to view what is going on is stop. 2 00:00:10,689 --> 00:00:15,140 And because stop offers management options as well, if you want to use 3 00:00:15,140 --> 00:00:19,589 these management options, then you might want to run it with sudo privileges. 4 00:00:20,390 --> 00:00:23,390 But for viewing processes, that isn't even necessary. 5 00:00:24,390 --> 00:00:30,899 So let's do a quick walkthrough of what we see starting on the top line, where we can see the amount of time that this system is up. 6 00:00:31,480 --> 00:00:34,200 10 hours, 12 minutes and a couple of seconds. 7 00:00:35,340 --> 00:00:40,799 We see the current time, we see the number of users currently active, and we see the load average. 8 00:00:41,759 --> 00:00:45,500 The load average as we call it, is the average number of runnable processes. 9 00:00:46,460 --> 00:00:50,079 That is a process that is candidate for asking attention from 10 00:00:50,079 --> 00:00:53,700 the scheduler. So it needs to run on the CPU. 11 00:00:54,630 --> 00:01:00,890 We have three figures for the last 1, 5 and 15 minutes and you can see they are all below 1. 12 00:01:01,429 --> 00:01:02,770 So nothing is going on here. 13 00:01:03,429 --> 00:01:09,920 If you want to know what is good for your system, you need to relate this to the number of CPU cores on your system. 14 00:01:10,579 --> 00:01:16,166 Every CPU core can handle one process at a time. So on a one core system, 15 00:01:16,166 --> 00:01:21,753 one is the highest that you should see. And on a 32 core system, 32 is 16 00:01:21,753 --> 00:01:27,340 the highest theoretical capacity you see. Anything higher than that, you need further investigation. 17 00:01:27,890 --> 00:01:32,170 Now you might be wondering how many CPUs do I have? Well, in top, if you press one 18 00:01:32,170 --> 00:01:36,450 on the third and fourth line in this case you see a line for every single cpu. 19 00:01:37,010 --> 00:01:38,370 So this is a two core system. 20 00:01:39,510 --> 00:01:44,980 Then the second line is not very interesting. We can see the total number of processes and how many 21 00:01:44,980 --> 00:01:50,450 of them are running. So we have one active process and most of them are sleeping in the background. 22 00:01:50,969 --> 00:01:56,890 Then line number three is giving an indicator of what your processes currently are doing. 23 00:01:58,109 --> 00:02:05,000 Probably the most interesting parameter is the ID for idle loop. This is a percentage of time that your system is doing nothing. 24 00:02:05,799 --> 00:02:11,136 And if your system is doing something, you will see activity either in us or 25 00:02:11,136 --> 00:02:16,473 in sy. That's for user space and system space, where user space is for non 26 00:02:16,473 --> 00:02:21,810 privileged processes and system space is for processes that are running in kernel space. 27 00:02:22,409 --> 00:02:27,469 High system space, for instance, might indicate a lot of activity by drivers. 28 00:02:28,969 --> 00:02:30,270 Next we have memory usage. 29 00:02:30,889 --> 00:02:36,680 Now the interesting thing in memory usage is that you can see the total amount of memory, the 30 00:02:36,680 --> 00:02:42,470 amount of free memory and the amount of used memory. That's memory that's actively being used by programs. 31 00:02:43,770 --> 00:02:50,085 Also we have buffers and cache. So this system has about a gigabyte of buffers and cache, and 32 00:02:50,085 --> 00:02:56,400 the system is using that to make sure that memory is addressed in the most Efficient way. 33 00:02:56,919 --> 00:03:03,219 What does that mean? Well, if you read a file from disk, before the file can be served to a user, it needs to be copied to memory. 34 00:03:03,879 --> 00:03:06,889 Cache means that you keep it in memory as long as possible. 35 00:03:07,509 --> 00:03:13,210 And if your file is still in cache, the next user that is going to need it can serve it from cache. And that's efficient. 36 00:03:14,289 --> 00:03:19,714 BURFIS is mainly for writing. If you write data, then the data is stored temporarily in memory and from 37 00:03:19,714 --> 00:03:25,139 memory it will be flushed to disk so that it can be written in the most efficient way. 38 00:03:25,900 --> 00:03:29,280 Now, buffers and cache are mainly used for optimization of your system. 39 00:03:30,139 --> 00:03:32,969 And a part of the buffers and cache is not really needed. 40 00:03:33,550 --> 00:03:37,360 And that is why we have this available memory parameter. 41 00:03:38,300 --> 00:03:43,120 In the available memory parameter we can see the amount of memory that can be liberated 42 00:03:43,120 --> 00:03:47,939 immediately if we also dump the memory that is not really needed in buffers and cache. 43 00:03:49,300 --> 00:03:50,800 And last, there is swap. 44 00:03:51,500 --> 00:03:55,900 Swap is a little bit slower than memory. And how much slower that depends on your storage. 45 00:03:56,430 --> 00:04:02,413 If you're on modern NVMe it's not that bad. If you're on an old rotating hard disk, then it 46 00:04:02,413 --> 00:04:08,396 is significantly slower. The Linux kernel normally is using swap in a very efficient way and it is pausing 47 00:04:08,396 --> 00:04:14,379 program memory that is not actively being used in the swap. And that's what we can see here. 48 00:04:14,520 --> 00:04:16,759 It's using 351 megabytes of swap to moment. 49 00:04:20,860 --> 00:04:24,480 Now notice that these highlighted parameters relate to swap. The 50 00:04:24,480 --> 00:04:28,100 other one, the available memory is more the generic overview. 51 00:04:29,100 --> 00:04:33,889 And last but not least, in top you see the top list of most active processes. 52 00:04:34,410 --> 00:04:39,175 It refreshes every five seconds. So if you are looking for the most 53 00:04:39,175 --> 00:04:43,939 active process sorted by CPU utilization, that's the one that is listed first. 54 00:04:44,839 --> 00:04:48,589 And if you press uppercase M, you you would sort by memory utilization. 55 00:04:49,269 --> 00:04:52,209 If you are looking for processes that are occupying a lot of memory. 56 00:04:53,129 --> 00:04:56,439 And that concludes our quick walkthrough of the top utility.