1 00:00:06,208 --> 00:00:07,950 - Okay. In the previous video 2 00:00:07,950 --> 00:00:10,800 you have learned how to use man, man is awesome. 3 00:00:10,800 --> 00:00:13,305 As long as you know which command to use 4 00:00:13,305 --> 00:00:14,988 but what are you going to do 5 00:00:14,988 --> 00:00:16,740 if you don't know which command to use? 6 00:00:16,740 --> 00:00:21,030 Well, then you are going to use the man DB. 7 00:00:21,030 --> 00:00:22,308 The thing is that an index 8 00:00:22,308 --> 00:00:26,760 of man pages is created in the man DB, the man database. 9 00:00:26,760 --> 00:00:28,530 And you can use man minus K 10 00:00:28,530 --> 00:00:32,400 or apropos to search the man DB on keywords. 11 00:00:32,400 --> 00:00:35,045 In some cases you will get nothing appropriate. 12 00:00:35,045 --> 00:00:36,270 If that happens. 13 00:00:36,270 --> 00:00:39,570 If you are looking for something, not very common 14 00:00:39,570 --> 00:00:42,900 then it may happen that there's just nothing matching 15 00:00:42,900 --> 00:00:44,069 or you are looking for. 16 00:00:44,069 --> 00:00:48,810 But it may also mean that your man DB is not updated. 17 00:00:48,810 --> 00:00:51,690 And if that is the case, well, you need to update it. 18 00:00:51,690 --> 00:00:54,480 Sudo, man, DB is what you are going to use. 19 00:00:54,480 --> 00:00:55,623 Let me demonstrate. 20 00:00:56,728 --> 00:00:58,320 (keyboard typing) 21 00:00:58,320 --> 00:00:59,153 All right. 22 00:00:59,153 --> 00:01:00,390 I am typing man 23 00:01:00,390 --> 00:01:04,350 minus K man, minus K or apropos it's the same. 24 00:01:04,350 --> 00:01:06,540 So you decide what you want to use. 25 00:01:06,540 --> 00:01:09,420 I'm using man minus K user and oh no 26 00:01:09,420 --> 00:01:11,340 I am getting nothing appropriate. 27 00:01:11,340 --> 00:01:12,875 That is definitely not good. 28 00:01:12,875 --> 00:01:14,760 But it's something that may happen 29 00:01:14,760 --> 00:01:16,350 on newly installed systems. 30 00:01:16,350 --> 00:01:18,548 So how come isn't this taken care 31 00:01:18,548 --> 00:01:22,849 of when installing the system? Well actually no. 32 00:01:22,849 --> 00:01:25,914 The thing is that the man DB is generated 33 00:01:25,914 --> 00:01:30,720 by a scheduled job, a Cron job, as you call it in Linux. 34 00:01:30,720 --> 00:01:34,556 And this Cron job runs every, every day, once a day. 35 00:01:34,556 --> 00:01:37,888 And this system was installed not so very long ago. 36 00:01:37,888 --> 00:01:40,170 So this is a brand new system 37 00:01:40,170 --> 00:01:42,515 and that means that the Cron job has 38 00:01:42,515 --> 00:01:44,499 just not been started yet. 39 00:01:44,499 --> 00:01:45,570 And you know what 40 00:01:45,570 --> 00:01:47,580 I'm going to show you? man 41 00:01:47,580 --> 00:01:50,280 so that we can actually practice using man and 42 00:01:50,280 --> 00:01:54,290 and find out how to use man minus K. 43 00:01:54,290 --> 00:01:56,490 So man, man, and I'm going to search 44 00:01:56,490 --> 00:01:58,807 for minus K so slash minus K. 45 00:01:58,807 --> 00:02:00,473 Look at the lower left corner 46 00:02:00,473 --> 00:02:03,450 slash minus K is bringing me 47 00:02:03,450 --> 00:02:05,730 to the first and the second occurrence. 48 00:02:05,730 --> 00:02:07,465 That's not what I need. 49 00:02:07,465 --> 00:02:11,040 So I'm pressing N to get to the next and N again and there 50 00:02:11,040 --> 00:02:12,930 We can see equivalent 51 00:02:12,930 --> 00:02:15,660 to apropos search the short manual descriptions 52 00:02:15,660 --> 00:02:17,839 see apropos for details. 53 00:02:17,839 --> 00:02:20,882 So we are in the wrong spot and I need to use man 54 00:02:20,882 --> 00:02:24,709 on apropos to get the appropriate information. 55 00:02:24,709 --> 00:02:27,467 And there we get an explanation 56 00:02:27,467 --> 00:02:30,120 and we can see the database searched 57 00:02:30,120 --> 00:02:33,870 by apropos is updated by the man DB program. 58 00:02:33,870 --> 00:02:37,800 So man DB program, and it's also telling us this may be run 59 00:02:37,800 --> 00:02:39,210 by a periodic Cron job. 60 00:02:39,210 --> 00:02:41,310 That's exactly what was happening 61 00:02:41,310 --> 00:02:43,470 but how do we deal with this man DB? 62 00:02:43,470 --> 00:02:47,234 Well, man, should know, man, man DB, there we go. 63 00:02:47,234 --> 00:02:50,071 And man DB always do a quick check. 64 00:02:50,071 --> 00:02:52,200 If you're in the right section 65 00:02:52,200 --> 00:02:54,600 if you see a one or an eight, then you are good. 66 00:02:55,553 --> 00:02:58,020 If you see a three or something else that is not a one 67 00:02:58,020 --> 00:03:01,290 or an eight, then are probably in the wrong location. 68 00:03:01,290 --> 00:03:02,460 So what do we see? 69 00:03:02,460 --> 00:03:06,240 We see that man DB comes from section eight 70 00:03:06,240 --> 00:03:09,072 section eight means that it's an admin command. 71 00:03:09,072 --> 00:03:10,133 And that means 72 00:03:10,133 --> 00:03:10,966 (keyboard typing) 73 00:03:10,966 --> 00:03:13,890 that if I want to regenerate the man DB just 74 00:03:13,890 --> 00:03:16,233 typing man DB is not going to work. 75 00:03:17,550 --> 00:03:20,820 As you can see, I'm getting warning cannot create 76 00:03:20,820 --> 00:03:23,611 and more warning cannot create, cannot create. 77 00:03:23,611 --> 00:03:26,280 That means that we have a permission issue. 78 00:03:26,280 --> 00:03:28,950 So I'm going to repeat this command. 79 00:03:28,950 --> 00:03:30,330 I look at my command line. 80 00:03:30,330 --> 00:03:32,760 I have my cursor blinking at the end of the line. 81 00:03:32,760 --> 00:03:34,710 I'm using control A 82 00:03:34,710 --> 00:03:37,650 control a brings your cursor to the start of the line 83 00:03:37,650 --> 00:03:39,780 and control E to the end of the line. 84 00:03:39,780 --> 00:03:41,130 But I need to be at the start 85 00:03:41,130 --> 00:03:45,210 of the line because I want to type sudo in front of it. 86 00:03:45,210 --> 00:03:48,060 And of course you can remove this command and try again 87 00:03:48,060 --> 00:03:50,010 but it's so much more convenient. 88 00:03:50,010 --> 00:03:53,190 If you can just move your cursor 89 00:03:53,190 --> 00:03:56,190 to the start of the line, I'm using sudo. 90 00:03:56,190 --> 00:03:59,190 And in order to do sudo, I need my password. 91 00:03:59,190 --> 00:04:00,030 There we go. 92 00:04:00,030 --> 00:04:03,273 And now it is updating the man DB. 93 00:04:03,273 --> 00:04:05,910 Even if it's doing the right thing 94 00:04:05,910 --> 00:04:08,753 you do see a couple of field messages. 95 00:04:08,753 --> 00:04:10,710 Please ignore the field messages. 96 00:04:10,710 --> 00:04:11,543 What you should be looking 97 00:04:12,793 --> 00:04:14,550 for is the third line from the bottom. 98 00:04:14,550 --> 00:04:18,960 Almost 8,000 manual pages were edited and the result is 99 00:04:18,960 --> 00:04:22,860 that right now I can use man minus K user. 100 00:04:22,860 --> 00:04:26,100 And oh boy, did you see that? 101 00:04:26,100 --> 00:04:28,500 This is what I call too much output. 102 00:04:28,500 --> 00:04:31,560 Sometimes on Linux, you get too much output 103 00:04:31,560 --> 00:04:33,990 and I will tell you in much more detail 104 00:04:33,990 --> 00:04:35,550 what we are going to do later 105 00:04:35,550 --> 00:04:39,180 but now I'm going to give you a quick look ahead. 106 00:04:39,180 --> 00:04:43,144 If you get so much output, use a pipe, the pipe 107 00:04:43,144 --> 00:04:46,230 will take the result of the first command and use it 108 00:04:46,230 --> 00:04:48,060 as input for the second command. 109 00:04:48,060 --> 00:04:51,870 And you have two options, man, minus K user pipe, less 110 00:04:51,870 --> 00:04:55,950 which will, which will send it to the less pager. 111 00:04:55,950 --> 00:04:58,380 And in this pager, you can watch the results screen 112 00:04:58,380 --> 00:05:01,410 by screen, use a space bar to move forward. 113 00:05:01,410 --> 00:05:04,020 But Hey, this is still too much reading. 114 00:05:04,020 --> 00:05:06,720 Maybe you wanna do something smarter. 115 00:05:06,720 --> 00:05:09,450 If we repeat the output of man minus K, 116 00:05:09,450 --> 00:05:11,910 Then you can see that in the first column 117 00:05:11,910 --> 00:05:14,130 there is the section behind all of the commands 118 00:05:14,130 --> 00:05:16,510 and we are going to use this section number to 119 00:05:17,425 --> 00:05:19,290 find the command that we need. 120 00:05:19,290 --> 00:05:20,250 Now, what is the thing? 121 00:05:20,250 --> 00:05:23,696 If I'm looking for users and probably I'm looking 122 00:05:23,696 --> 00:05:25,740 for something like I wanna create a user 123 00:05:25,740 --> 00:05:28,290 and what do you think, can you create a user 124 00:05:28,290 --> 00:05:31,138 without using sudo? Of course not creating user 125 00:05:31,138 --> 00:05:33,436 requires root privileges. 126 00:05:33,436 --> 00:05:36,150 And that means that the command that I'm looking 127 00:05:36,150 --> 00:05:39,951 for most likely is documented in section eight. 128 00:05:39,951 --> 00:05:41,400 (typing) 129 00:05:41,400 --> 00:05:44,490 So I'm going to pipe this time, the output 130 00:05:44,490 --> 00:05:47,349 of man minus K user to the grep command. 131 00:05:47,349 --> 00:05:50,430 He grep command is also one of these commands 132 00:05:50,430 --> 00:05:53,220 that we will explore in much more detail later. 133 00:05:53,220 --> 00:05:56,760 But for now you should know that the grep command is one of 134 00:05:56,760 --> 00:05:59,100 The most useful commands in Linux. 135 00:05:59,100 --> 00:06:01,200 It's a filtering utility and 136 00:06:01,200 --> 00:06:04,230 by piping the output to grep eight man minus K 137 00:06:04,230 --> 00:06:08,147 user is only going to show these lines that contain an eight 138 00:06:08,147 --> 00:06:10,020 and there near the bottom 139 00:06:10,020 --> 00:06:13,680 you can see user add and user del and user mod. 140 00:06:13,680 --> 00:06:16,440 And in case you are wondering why doesn't man 141 00:06:16,440 --> 00:06:20,165 minus K have an option to work with specific 142 00:06:20,165 --> 00:06:22,710 specific sections of man. 143 00:06:22,710 --> 00:06:23,940 Well, that is because 144 00:06:23,940 --> 00:06:27,480 of something that we call the Linux philosophy. 145 00:06:27,480 --> 00:06:28,740 In the Linux philosophy 146 00:06:28,740 --> 00:06:32,370 It's very common not to program all the functionality 147 00:06:32,370 --> 00:06:33,300 in one command 148 00:06:33,300 --> 00:06:36,720 because that would make one big bloated command. 149 00:06:36,720 --> 00:06:39,840 You wanna make sure that you pipe the output of one command 150 00:06:39,840 --> 00:06:42,480 to another command, which is a smart combination 151 00:06:42,480 --> 00:06:46,440 of commands to get you exactly the result that you wanna do. 152 00:06:46,440 --> 00:06:51,030 So this is why we are using pipes a lot 153 00:06:51,030 --> 00:06:53,310 in Linux to combine functionality. 154 00:06:53,310 --> 00:06:55,980 And by the time you are done with this course 155 00:06:55,980 --> 00:06:57,210 you will know how to do it 156 00:06:57,210 --> 00:06:58,043 Exactly.