1 00:00:00,000 --> 00:00:04,400 [Intro Music] 2 00:00:04,410 --> 00:00:06,090 Let me now briefly summarize what 3 00:00:06,090 --> 00:00:07,440 we did during previous few 4 00:00:07,440 --> 00:00:09,600 lectures. First we have used 5 00:00:09,600 --> 00:00:11,500 apt-get utility in order to 6 00:00:11,520 --> 00:00:14,580 install missing htop package. This 7 00:00:14,580 --> 00:00:16,620 package is missing in this Ubuntu 8 00:00:16,620 --> 00:00:18,240 image that we are running using 9 00:00:18,270 --> 00:00:20,850 Docker. We have actually used the apt- 10 00:00:20,850 --> 00:00:23,070 get before in order to install other 11 00:00:23,070 --> 00:00:25,440 package called 'mandb' in order to 12 00:00:25,440 --> 00:00:28,080 get the man pages working in Linux 13 00:00:28,110 --> 00:00:30,690 computer. I have also shown you how 14 00:00:30,720 --> 00:00:33,119 to run htop utility, and how to get 15 00:00:33,119 --> 00:00:34,740 information about the currently 16 00:00:34,770 --> 00:00:36,990 running processes. You could also 17 00:00:36,990 --> 00:00:38,520 perform other actions with those 18 00:00:38,520 --> 00:00:40,710 processes like kill processes and 19 00:00:40,710 --> 00:00:42,720 filter them if you want. Also 20 00:00:42,720 --> 00:00:44,760 using htop utility, you could 21 00:00:44,790 --> 00:00:47,430 observe how much CPU and memory are 22 00:00:47,430 --> 00:00:49,380 currently used by all running 23 00:00:49,380 --> 00:00:52,020 processes. And I see that CPU 24 00:00:52,020 --> 00:00:54,660 consumption is around 2%, and 25 00:00:54,660 --> 00:00:57,210 memory consumption is around 300 26 00:00:57,210 --> 00:00:59,760 megabytes. Also, I see here limit 27 00:00:59,790 --> 00:01:02,760 2.92 gigabytes. And actually 28 00:01:02,760 --> 00:01:05,190 it is a limit of Docker Host. I 29 00:01:05,190 --> 00:01:06,810 could go to Docker Settings and 30 00:01:06,810 --> 00:01:08,610 quickly demonstrate it. Go to 31 00:01:08,610 --> 00:01:12,300 Dashboard, click on Settings icon, 32 00:01:12,330 --> 00:01:14,610 go to Resources, and here is this 33 00:01:14,610 --> 00:01:17,160 memory limit, 3 gigabytes. And 34 00:01:17,160 --> 00:01:18,960 here is also Swap size, 1 35 00:01:18,960 --> 00:01:21,090 gigabyte. And you actually see this 36 00:01:21,090 --> 00:01:22,980 limit here in this table as well. 37 00:01:23,370 --> 00:01:25,230 It means that this Docker container 38 00:01:25,320 --> 00:01:27,300 is able to utilize up to three 39 00:01:27,300 --> 00:01:29,490 gigabytes of RAM and up to one 40 00:01:29,520 --> 00:01:32,490 gigabyte of swap size. Great. But 41 00:01:32,490 --> 00:01:34,380 the main idea why I wanted to show 42 00:01:34,380 --> 00:01:36,690 you this htop utility is that it 43 00:01:36,690 --> 00:01:38,460 actually shows out of the box 44 00:01:38,490 --> 00:01:40,980 command that was used for start of 45 00:01:40,980 --> 00:01:43,470 corresponding process. Actually, 46 00:01:43,470 --> 00:01:45,360 you could use additional option 47 00:01:45,390 --> 00:01:47,610 along with 'ps' command. Let me show 48 00:01:47,610 --> 00:01:49,920 you this quickly; 'ps -f'; 49 00:01:50,160 --> 00:01:51,840 and with this option, you could 50 00:01:51,870 --> 00:01:54,210 also see command that was used for 51 00:01:54,210 --> 00:01:56,190 start of corresponding process. For 52 00:01:56,190 --> 00:01:58,290 example, I have just entered 'ps 53 00:01:58,290 --> 00:02:00,240 -f' command, that's why here in 54 00:02:00,240 --> 00:02:02,500 this list, I see 'ps' along with 55 00:02:02,500 --> 00:02:05,200 '-f' option. Great. That is how you 56 00:02:05,220 --> 00:02:08,130 could use ps, top and htop utility. 57 00:02:08,340 --> 00:02:10,020 Now let me do for you quick demo 58 00:02:10,110 --> 00:02:12,810 and run htop utility on another 59 00:02:12,810 --> 00:02:14,940 Ubuntu computer that has much more 60 00:02:14,940 --> 00:02:17,070 processes than this container. Let 61 00:02:17,070 --> 00:02:19,620 me switch there, and enter 'htop' 62 00:02:19,620 --> 00:02:21,720 here. It is available here out of 63 00:02:21,720 --> 00:02:24,180 the box. And here's a long list of 64 00:02:24,210 --> 00:02:26,070 different processes. And you may 65 00:02:26,070 --> 00:02:27,630 see that some of processes were 66 00:02:27,630 --> 00:02:30,300 started by root user and some by 67 00:02:30,330 --> 00:02:33,060 bogdan user. Actually, you could 68 00:02:33,150 --> 00:02:35,700 run htop utility along with option 69 00:02:35,760 --> 00:02:38,220 that will filter processes by user. 70 00:02:38,550 --> 00:02:40,830 Let me quickly show you that, 'htop 71 00:02:40,890 --> 00:02:43,650 --help'; and here you will 72 00:02:43,650 --> 00:02:46,290 see this option '-u', it is 73 00:02:46,320 --> 00:02:48,180 short version of this option, or 74 00:02:48,210 --> 00:02:51,330 long version is '--user'. And 75 00:02:51,330 --> 00:02:53,340 if you use this option, you need to 76 00:02:53,340 --> 00:02:55,380 supply mandatory argument for this 77 00:02:55,410 --> 00:02:57,000 option. Recap that we have talked 78 00:02:57,000 --> 00:02:58,920 about arguments for options before. 79 00:02:59,640 --> 00:03:01,560 And for example, if I want to list 80 00:03:01,590 --> 00:03:04,080 only my processes, I could use this 81 00:03:04,110 --> 00:03:07,380 option, 'htop -u'; and if I 82 00:03:07,380 --> 00:03:09,690 use short version of option, I need 83 00:03:09,690 --> 00:03:11,790 to supply argument for option after 84 00:03:11,790 --> 00:03:14,730 space like so, '-u ', and 85 00:03:14,730 --> 00:03:18,060 type my name. And now I see only my 86 00:03:18,090 --> 00:03:20,670 processes here in this table. Let 87 00:03:20,670 --> 00:03:23,370 me exit from here. And let's list 88 00:03:23,400 --> 00:03:25,770 all processes that were started by 89 00:03:25,830 --> 00:03:28,290 root user; and let me use long 90 00:03:28,350 --> 00:03:31,247 version of this option, '--user'; 91 00:03:31,247 --> 00:03:32,730 and in such case, I need 92 00:03:32,730 --> 00:03:35,130 to use here equal sign and type 93 00:03:35,160 --> 00:03:37,710 name of the user 'root', like so, press 94 00:03:37,740 --> 00:03:39,690 Enter, and now I see processes that 95 00:03:39,690 --> 00:03:42,540 were started only by 'root' user. All 96 00:03:42,540 --> 00:03:44,520 right, let me exit from here. And 97 00:03:44,550 --> 00:03:46,890 let me start htop without any 98 00:03:46,920 --> 00:03:49,710 additional options like this. And 99 00:03:49,710 --> 00:03:50,790 let me show you how you could 100 00:03:50,790 --> 00:03:52,860 perform for example, filtering of 101 00:03:53,040 --> 00:03:55,050 processes. For that you could press 102 00:03:55,050 --> 00:03:56,880 F4; and let's filter for 103 00:03:56,880 --> 00:03:59,340 example by 'bash'; and now I will 104 00:03:59,340 --> 00:04:01,620 find 'bash' process that was started 105 00:04:01,620 --> 00:04:04,050 by 'bogdan' user. Also let's 106 00:04:04,050 --> 00:04:07,320 filter for example by 'gnome', like 107 00:04:07,320 --> 00:04:09,090 so. And now I will see all 108 00:04:09,090 --> 00:04:10,890 processes that have 'gnome' 109 00:04:10,920 --> 00:04:12,780 somewhere in the process name. 110 00:04:13,200 --> 00:04:14,790 Alright, that's how you could filter 111 00:04:14,790 --> 00:04:16,350 processes. Now let me 112 00:04:16,350 --> 00:04:17,940 demonstrate to you how to sort 113 00:04:17,940 --> 00:04:19,320 processes. For that you 114 00:04:19,320 --> 00:04:22,019 could use F6. Let me press it. And 115 00:04:22,019 --> 00:04:24,240 here in the left section, you could 116 00:04:24,269 --> 00:04:27,540 sort for example by PERCENT_MEM; 117 00:04:27,899 --> 00:04:30,000 and now I see that all processes 118 00:04:30,000 --> 00:04:32,550 were sorted by percentage of memory 119 00:04:32,550 --> 00:04:34,800 usage. And here is the process that 120 00:04:34,800 --> 00:04:37,830 utilizes around 6% of memory. It is 121 00:04:37,830 --> 00:04:39,630 actually this graphical user 122 00:04:39,660 --> 00:04:41,760 interface desktop I am currently 123 00:04:41,790 --> 00:04:45,180 working in, nautilus-desktop. Okay. 124 00:04:45,420 --> 00:04:48,120 Also you see limits of this 125 00:04:48,150 --> 00:04:51,060 computer. And now one gigabyte of 126 00:04:51,060 --> 00:04:53,190 RAM is utilized and the maximum 127 00:04:53,190 --> 00:04:55,800 size is two gigabytes. And actually 128 00:04:55,800 --> 00:04:58,200 I'm running this Ubuntu computer as 129 00:04:58,230 --> 00:05:00,450 virtual machine using VMware Fusion, 130 00:05:00,630 --> 00:05:02,550 and I have set the limit of two 131 00:05:02,550 --> 00:05:04,710 gigabytes of RAM for this computer. 132 00:05:04,770 --> 00:05:06,570 That's why here I see this limit, 133 00:05:06,810 --> 00:05:09,570 two gigabytes. Alright, that's all 134 00:05:09,570 --> 00:05:11,100 for this demonstration. And please 135 00:05:11,100 --> 00:05:12,300 note that if you don't have 136 00:05:12,300 --> 00:05:14,100 separate Ubuntu computer, no 137 00:05:14,100 --> 00:05:16,050 worries, you are still good to go 138 00:05:16,050 --> 00:05:18,240 just with Linux container running 139 00:05:18,390 --> 00:05:20,910 using Docker. That's all for those 140 00:05:20,910 --> 00:05:23,130 lectures about processes. I hope 141 00:05:23,130 --> 00:05:24,840 you enjoyed them. And next let me 142 00:05:24,840 --> 00:05:27,330 talk about the standard in - stdin, standard 143 00:05:27,390 --> 00:05:29,790 out - stdout, and standard error - stderr of every 144 00:05:29,790 --> 00:05:31,920 process. You'll understand those 145 00:05:31,950 --> 00:05:34,140 three different data flows of every 146 00:05:34,140 --> 00:05:35,910 process, and you'll understand how 147 00:05:35,910 --> 00:05:37,800 to use them. I will see you guys in 148 00:05:37,800 --> 00:05:38,958 the next lecture. Bye-Bye. 149 00:05:38,958 --> 00:05:40,928 [no audio]