1 00:00:00,000 --> 00:00:01,930 [No audio] 2 00:00:01,930 --> 00:00:02,986 System Monitoring. 3 00:00:03,058 --> 00:00:06,774 Now we are getting deep into the system administration type 4 00:00:06,812 --> 00:00:10,986 of commands or roles that you will be working 5 00:00:11,048 --> 00:00:14,394 on. If you really want to get a job in 6 00:00:14,432 --> 00:00:19,458 system administration or systems engineering or Linux related field, you 7 00:00:19,484 --> 00:00:22,666 do need to know all those system monitoring commands. 8 00:00:22,798 --> 00:00:28,710 Some of them are top, df, dmesg, iostat, 9 00:00:29,150 --> 00:00:34,986 netstat, free, and cpuinfo, and meminfo. 10 00:00:35,168 --> 00:00:38,514 All these commands will list all the system resources and 11 00:00:38,552 --> 00:00:42,582 will tell you how the system is doing, how is 12 00:00:42,596 --> 00:00:45,438 it behaving, whether it's running high or low. 13 00:00:45,524 --> 00:00:48,322 So let's look at them one by one by logging 14 00:00:48,346 --> 00:00:53,730 into our Linux machine, log into our VM console. 15 00:00:53,730 --> 00:00:58,710 [No audio] 16 00:00:58,710 --> 00:01:00,442 All right, the top command you 17 00:01:00,456 --> 00:01:02,110 can run without being root. 18 00:01:03,750 --> 00:01:07,370 So if you notice in the top command 19 00:01:07,550 --> 00:01:11,842 once again, it has cpu information, memory information, 20 00:01:12,036 --> 00:01:14,710 it tells you which process it's on, which 21 00:01:14,820 --> 00:01:17,290 user is running, and what command it's running. 22 00:01:17,400 --> 00:01:22,366 This is again one very powerful command and you should really 23 00:01:22,428 --> 00:01:29,806 spend some time to look into every field, and I would 24 00:01:29,868 --> 00:01:34,630 highly recommend you to go look for the documentation or Google 25 00:01:34,680 --> 00:01:37,762 it and find out more information about it. If you want 26 00:01:37,776 --> 00:01:39,482 to get out of it, hit q. 27 00:01:39,626 --> 00:01:41,798 The next one we have df. 28 00:01:41,954 --> 00:01:46,860 df gives you your disk partition information. 29 00:01:47,670 --> 00:01:51,374 You could run df minus man space df, 30 00:01:51,422 --> 00:01:55,570 it tells you report file system disk usage. 31 00:01:56,490 --> 00:02:00,346 We'll run df again and it tells you 32 00:02:00,408 --> 00:02:04,186 the file system is mapped right here. 33 00:02:04,308 --> 00:02:06,826 It has this block, this is available, 34 00:02:06,948 --> 00:02:08,264 what percent is used. 35 00:02:08,388 --> 00:02:12,454 Now, the most common options that is used 36 00:02:12,491 --> 00:02:16,334 with df is -h. h is easier, it's 37 00:02:16,382 --> 00:02:18,886 human readable, it's easy to understand. 38 00:02:19,068 --> 00:02:22,246 So now it tells you we have a disk size 39 00:02:22,428 --> 00:02:26,674 at the root level, which is eight gig and 3.4 40 00:02:26,712 --> 00:02:31,402 gig is used and 4.6 is available and uses 43%, 41 00:02:31,476 --> 00:02:34,234 it also gives you a percentage, and so on 42 00:02:34,272 --> 00:02:36,722 is the memory, which is about two gig. 43 00:02:36,866 --> 00:02:39,118 And then we have a boot file system 44 00:02:39,204 --> 00:02:42,578 which when the system boots everything is located, 45 00:02:42,674 --> 00:02:46,210 and what to boot, which files to boot. 46 00:02:46,650 --> 00:02:51,034 It has one gig, and so one gig here, eight 47 00:02:51,072 --> 00:02:55,474 gig here, so nine gig, and this free memory, which is 48 00:02:55,512 --> 00:02:58,034 the swap, or virtual memory is about one gig. 49 00:02:58,142 --> 00:02:59,882 That makes it ten gigs. 50 00:02:59,966 --> 00:03:02,098 And if you remember we created our 51 00:03:02,124 --> 00:03:04,142 virtual machine with ten gig and that's 52 00:03:04,166 --> 00:03:06,360 what it's telling you, the partition information. 53 00:03:07,170 --> 00:03:10,762 If your system is dead or crashed, one of 54 00:03:10,776 --> 00:03:13,358 the things you should look into it is df 55 00:03:13,394 --> 00:03:16,930 -h output, once again df -h. 56 00:03:17,100 --> 00:03:21,022 And if the usage right here says 100%, or any of 57 00:03:21,036 --> 00:03:26,278 the usage says 100%, then definitely you are in trouble, and 58 00:03:26,304 --> 00:03:29,638 you need to free up your disk space, and you need 59 00:03:29,664 --> 00:03:32,602 to find out how to free up your disk space. 60 00:03:32,676 --> 00:03:36,158 You need another command that is you sorry, du. 61 00:03:36,254 --> 00:03:39,226 You could do man on du and learn more about it. 62 00:03:39,288 --> 00:03:41,930 It tells you the estimated file space usage, 63 00:03:41,990 --> 00:03:44,100 which file is taking up all the space. 64 00:03:45,030 --> 00:03:47,220 Next command we have dmesg. 65 00:03:48,810 --> 00:03:53,494 dmesg gives you the output of the 66 00:03:53,532 --> 00:03:57,814 system related warnings, error messages, failures or 67 00:03:57,852 --> 00:04:00,058 anything like that. When you run it, 68 00:04:00,084 --> 00:04:02,678 of course it throws bunch of error messages, 69 00:04:02,714 --> 00:04:04,486 a bunch of information at you. 70 00:04:04,548 --> 00:04:06,346 And if you want to view that one 71 00:04:06,408 --> 00:04:08,734 page at a time, what do you do? 72 00:04:08,892 --> 00:04:12,754 You pipe it to more. When you pipe it to more, 73 00:04:12,792 --> 00:04:15,732 you will see, it gives you the BIOS information, 74 00:04:16,170 --> 00:04:19,534 when the system initialized, how it went to what 75 00:04:19,572 --> 00:04:22,958 CPU, if there is any issues with the memory, 76 00:04:23,113 --> 00:04:25,774 it will report you right here. 77 00:04:25,812 --> 00:04:27,622 If there's a memory leak, if there's an 78 00:04:27,636 --> 00:04:30,946 issue with CPU that's crashed, motherboard issue. 79 00:04:31,128 --> 00:04:32,962 Anything related to your system 80 00:04:33,036 --> 00:04:35,542 hardware will be listed here. 81 00:04:35,676 --> 00:04:38,098 And this is again one of the good things that 82 00:04:38,124 --> 00:04:41,930 you should look at, if you are in system administration, 83 00:04:42,110 --> 00:04:45,074 If you are going for an interview, the interviewer 84 00:04:45,122 --> 00:04:47,234 is going to ask you give me the commands 85 00:04:47,282 --> 00:04:49,522 that you use to monitor your system. 86 00:04:49,656 --> 00:04:50,974 These are the commands, you 87 00:04:51,012 --> 00:04:52,678 should list them right away. 88 00:04:52,824 --> 00:04:54,598 And I'm telling you, he or she will 89 00:04:54,624 --> 00:04:57,322 be impressed right away that you know your 90 00:04:57,396 --> 00:04:59,894 commands, you know your system administration skills. 91 00:05:00,002 --> 00:05:03,207 The next command we will learn is iostat. 92 00:05:03,207 --> 00:05:07,838 IO stands for input and output statistics. What's 93 00:05:07,874 --> 00:05:10,790 coming in, what's going out, how we are communicating 94 00:05:10,850 --> 00:05:14,498 with our system peripheral devices or system internal devices, 95 00:05:14,594 --> 00:05:17,974 even if it's a disk or network. When you run 96 00:05:18,012 --> 00:05:21,178 it, it's going to give you the information right away 97 00:05:21,324 --> 00:05:25,318 that the disk is being used with the read per 98 00:05:25,344 --> 00:05:28,846 second, write per second, and a lot of different information. 99 00:05:29,028 --> 00:05:31,870 You could also run iostat with space 100 00:05:31,980 --> 00:05:35,078 one, which is telling it to refresh. 101 00:05:35,234 --> 00:05:39,310 Keep running it, but refresh it every 1 second. 102 00:05:39,420 --> 00:05:41,914 So it will refresh it, it will refresh it, it will keep 103 00:05:41,952 --> 00:05:44,386 telling you, keep updating you to read and write. 104 00:05:44,448 --> 00:05:46,270 If it is doing any read and write, 105 00:05:46,380 --> 00:05:48,682 it will update it as it goes. 106 00:05:48,816 --> 00:05:53,294 You could quit out of it by simply typing, 107 00:05:53,462 --> 00:05:57,720 I think you have to do control C to quit out of it. 108 00:05:58,170 --> 00:06:03,889 The next one we have netstat. netstat -rnv 109 00:06:03,889 --> 00:06:05,870 is the option that I mostly use 110 00:06:05,920 --> 00:06:08,522 if I want to find out my gateway information, 111 00:06:08,716 --> 00:06:12,990 If I wanted to find out my subnet mask, and what interface 112 00:06:13,050 --> 00:06:16,420 it is going through, this is the command I will use. 113 00:06:16,870 --> 00:06:20,022 There are other options that you could use with netstat. 114 00:06:20,166 --> 00:06:22,514 Just netstat, and if you pipe it, and you do 115 00:06:22,552 --> 00:06:24,410 more, you're going to see a lot of information. 116 00:06:24,520 --> 00:06:27,074 What is connected to your system, what has been 117 00:06:27,112 --> 00:06:31,480 disconnected, what's the process ID, which processes is it running, 118 00:06:33,078 --> 00:06:38,130 and, and the name of the owner of the process. 119 00:06:38,300 --> 00:06:41,094 So it does give you all the information. 120 00:06:41,252 --> 00:06:42,754 Once again, I apologize, 121 00:06:42,802 --> 00:06:45,198 I cannot cover every single detail. 122 00:06:45,344 --> 00:06:47,994 If I cover it, it's going to take me hours and 123 00:06:48,032 --> 00:06:51,790 hours, and days and days, to cover every single command. 124 00:06:51,850 --> 00:06:56,410 So my recommendation to you is just to simply 125 00:06:56,470 --> 00:07:02,718 man netstat, and you look into the description of 126 00:07:02,744 --> 00:07:05,134 this command, and the option of this command. 127 00:07:05,242 --> 00:07:08,142 Now please do remember, I've been doing the Linux for 128 00:07:08,156 --> 00:07:13,474 a very long time, and trust me, I myself don't 129 00:07:13,522 --> 00:07:18,018 know every single option that a command has to offer. 130 00:07:18,104 --> 00:07:21,090 If I wanted to find out or if I wanted 131 00:07:21,140 --> 00:07:24,102 to look for a specific output, then yes, then I 132 00:07:24,116 --> 00:07:26,586 will look into the options that is available. 133 00:07:26,768 --> 00:07:30,126 But it's completely understandable that not every 134 00:07:30,188 --> 00:07:32,874 person needs to remember every command or 135 00:07:32,972 --> 00:07:36,058 every option associated with every command. 136 00:07:36,214 --> 00:07:39,870 The next command we have free. free gives you your 137 00:07:39,920 --> 00:07:43,098 physical memory, and your swap space, which is a 138 00:07:43,124 --> 00:07:47,802 virtual memory, utilization, usage, and free. 139 00:07:47,996 --> 00:07:54,414 The next one we have is cat. cat is to read the 140 00:07:54,452 --> 00:07:59,874 file of cpuinfo. Every time your computer is started, 141 00:07:59,972 --> 00:08:03,822 it keeps all its system resources information into 142 00:08:03,896 --> 00:08:08,250 files and those files are located in proc. 143 00:08:08,990 --> 00:08:11,238 This proc is the directory where 144 00:08:11,264 --> 00:08:13,038 it keeps us all system information. 145 00:08:13,184 --> 00:08:16,797 So you could just do simply cat /proc/cpuinfo, you 146 00:08:16,797 --> 00:08:19,830 will find your cpu information right here. 147 00:08:20,000 --> 00:08:21,694 If you want to know your memory 148 00:08:21,742 --> 00:08:26,314 information you could do /proc/meminfo. 149 00:08:26,422 --> 00:08:29,778 Of course it's throwing all the messages, all the 150 00:08:29,804 --> 00:08:33,258 screen multiple at one shot so you could just 151 00:08:33,284 --> 00:08:36,162 do simply pipe it, and more it, and you 152 00:08:36,176 --> 00:08:38,214 will view it one page at a time. 153 00:08:38,371 --> 00:08:43,230 So these are system monitoring commands. 154 00:08:44,090 --> 00:08:47,490 You do need to remember these specific 155 00:08:47,600 --> 00:08:49,385 commands on top of your head, 156 00:08:49,448 --> 00:08:51,922 if you are going for an interview, if you're 157 00:08:51,946 --> 00:08:54,666 going for a technical interview, or even if you 158 00:08:54,727 --> 00:08:59,238 are new to Linux environment and you want to 159 00:08:59,264 --> 00:09:05,418 learn more commands by monitoring the system resources, you 160 00:09:05,444 --> 00:09:06,912 should look into these commands. 161 00:09:06,912 --> 00:09:09,162 [No audio]