1 00:00:00,600 --> 00:00:01,950 Instructor: Welcome back. 2 00:00:01,950 --> 00:00:04,440 Here we are in our Kali Linux machine 3 00:00:04,440 --> 00:00:06,330 and it is time we finally learn 4 00:00:06,330 --> 00:00:08,610 how to use that mysterious tool 5 00:00:08,610 --> 00:00:10,920 that is set to be the most important tool 6 00:00:10,920 --> 00:00:12,003 that we must master. 7 00:00:12,930 --> 00:00:16,590 Don't worry, Terminal is not difficult to use. 8 00:00:16,590 --> 00:00:21,120 But before we get to open it and run bunch of the commands 9 00:00:21,120 --> 00:00:23,883 let us first define what Terminal is. 10 00:00:24,750 --> 00:00:25,623 So what is it? 11 00:00:27,000 --> 00:00:30,600 Terminal is a program that allows us to interact 12 00:00:30,600 --> 00:00:34,620 with Linux operating system using different commands. 13 00:00:34,620 --> 00:00:38,130 We can create files, delete files, create directories, 14 00:00:38,130 --> 00:00:41,220 run programs, set different tasks to execute, 15 00:00:41,220 --> 00:00:45,090 and we can do many more things using it. 16 00:00:45,090 --> 00:00:47,077 It is important you get used to it 17 00:00:47,077 --> 00:00:50,010 especially if you never used it before, 18 00:00:50,010 --> 00:00:53,970 because if you're coming from Windows or Mac OS 19 00:00:53,970 --> 00:00:57,450 you probably are used to opening files or folders 20 00:00:57,450 --> 00:01:01,320 by clicking on different icons and navigating like that. 21 00:01:01,320 --> 00:01:05,700 For example, on Windows we usually open files 22 00:01:05,700 --> 00:01:09,243 by double clicking on an icon and it'll open that folder. 23 00:01:10,290 --> 00:01:13,710 And on Linux we can actually do the same thing. 24 00:01:13,710 --> 00:01:16,320 So if I go right here and for example 25 00:01:16,320 --> 00:01:18,390 I want to open this home folder 26 00:01:18,390 --> 00:01:20,310 I will double click on that folder 27 00:01:20,310 --> 00:01:24,630 and it'll open the folder with all the files inside of it. 28 00:01:24,630 --> 00:01:27,690 But we don't want to be doing it like that. 29 00:01:27,690 --> 00:01:31,230 Let us see how we can do it using Terminal. 30 00:01:31,230 --> 00:01:32,790 So let us close this first 31 00:01:32,790 --> 00:01:35,310 and we already know how to open Terminal, 32 00:01:35,310 --> 00:01:39,093 right click on desktop and click open Terminal here. 33 00:01:40,800 --> 00:01:44,520 First thing that we notice is username 34 00:01:44,520 --> 00:01:45,930 that we have right here 35 00:01:45,930 --> 00:01:49,470 and the host name that we have right here. 36 00:01:49,470 --> 00:01:53,583 But we also noticed this /desktop. 37 00:01:54,780 --> 00:01:57,240 This means that our Terminal process 38 00:01:57,240 --> 00:02:00,630 has opened inside of the desktop directory. 39 00:02:00,630 --> 00:02:02,730 Does it always open there? 40 00:02:02,730 --> 00:02:07,320 Nope, it only opened there because we told it to open there. 41 00:02:07,320 --> 00:02:09,660 Remember, we right clicked on desktop 42 00:02:09,660 --> 00:02:11,883 and clicked open Terminal here. 43 00:02:13,140 --> 00:02:15,580 If we, for example, went to the home folder 44 00:02:18,810 --> 00:02:22,203 and right clicked here, open Terminal, 45 00:02:26,040 --> 00:02:29,283 it doesn't say /home like it did in desktop. 46 00:02:30,150 --> 00:02:33,003 It just gives us this way minus sign. 47 00:02:34,020 --> 00:02:35,880 Well that sign in Linux 48 00:02:35,880 --> 00:02:40,440 means that you are in your home directory of your user. 49 00:02:40,440 --> 00:02:43,110 And our user is called mrhacker, 50 00:02:43,110 --> 00:02:47,670 so the directory name should be /home/mrhacker. 51 00:02:47,670 --> 00:02:50,220 And to check the directory name 52 00:02:50,220 --> 00:02:53,730 we can type the command pwd. 53 00:02:53,730 --> 00:02:57,540 If we press Enter, it'll give us the current directory 54 00:02:57,540 --> 00:03:00,930 in which our Terminal process is running 55 00:03:00,930 --> 00:03:04,860 and it is /home/mrhacker. 56 00:03:04,860 --> 00:03:09,633 And this pwd simply just stands for print working directory. 57 00:03:10,500 --> 00:03:13,890 If we for example, go to the folder once again 58 00:03:13,890 --> 00:03:17,280 which is /home folder /mrhacker, 59 00:03:17,280 --> 00:03:20,100 and we double click on documents, 60 00:03:20,100 --> 00:03:22,020 try to open Terminal here. 61 00:03:22,020 --> 00:03:24,750 So open Terminal here. 62 00:03:24,750 --> 00:03:26,910 This will open a second Terminal 63 00:03:26,910 --> 00:03:31,910 and you will see right here that it says /documents. 64 00:03:32,010 --> 00:03:34,500 But do we always need to go to that folder 65 00:03:34,500 --> 00:03:36,870 and open Terminal inside of that folder 66 00:03:36,870 --> 00:03:40,020 for it to be inside of this directory? 67 00:03:40,020 --> 00:03:41,400 Of course, not. 68 00:03:41,400 --> 00:03:44,163 We can use a command called cd. 69 00:03:45,420 --> 00:03:47,370 And you should be familiar with this command 70 00:03:47,370 --> 00:03:49,233 since we already used it before. 71 00:03:50,100 --> 00:03:51,810 Let us test it out. 72 00:03:51,810 --> 00:03:56,190 Let's go to the documents directory from our home directory. 73 00:03:56,190 --> 00:03:58,120 So I'll just close the second Terminal 74 00:03:58,980 --> 00:04:02,190 and right here we are inside of our home directory, 75 00:04:02,190 --> 00:04:04,533 or /home/mrhacker. 76 00:04:05,760 --> 00:04:08,010 We know that inside of this directory 77 00:04:08,010 --> 00:04:10,470 there is a documents directory 78 00:04:10,470 --> 00:04:13,200 since we managed to open it right here. 79 00:04:13,200 --> 00:04:16,709 And to navigate to this directory using Terminal 80 00:04:16,709 --> 00:04:19,019 we can use the command cd 81 00:04:19,019 --> 00:04:22,263 and then the name of the directory, which is documents. 82 00:04:25,770 --> 00:04:29,250 We press Enter and here it is, 83 00:04:29,250 --> 00:04:32,310 we are in /documents directory. 84 00:04:32,310 --> 00:04:34,440 If we type pwd here, 85 00:04:34,440 --> 00:04:36,510 it'll tell us the current working directory 86 00:04:36,510 --> 00:04:40,383 is /home/mrhacker/documents. 87 00:04:41,910 --> 00:04:42,900 And for example, 88 00:04:42,900 --> 00:04:46,350 if we wanted to go one step or one directory back 89 00:04:46,350 --> 00:04:49,743 we can type the command cd and then two dots. 90 00:04:50,760 --> 00:04:54,960 What this command will do is it'll go one directory back 91 00:04:54,960 --> 00:04:57,540 and if I type pwd once again, 92 00:04:57,540 --> 00:05:02,103 we will now be again in /home/mrhacker directory. 93 00:05:02,970 --> 00:05:05,340 So these two dots tell the Terminal 94 00:05:05,340 --> 00:05:07,173 to go one directory back. 95 00:05:08,520 --> 00:05:09,353 Okay, great. 96 00:05:09,353 --> 00:05:11,910 But how can we know which subdirectories 97 00:05:11,910 --> 00:05:15,210 and files are in home directory, for example? 98 00:05:15,210 --> 00:05:17,760 If we knew there was documents directory in home folder, 99 00:05:17,760 --> 00:05:20,520 because we opened it right here, 100 00:05:20,520 --> 00:05:22,650 we didn't open it over Terminal 101 00:05:22,650 --> 00:05:25,863 we opened it right here from our desktop. 102 00:05:28,410 --> 00:05:29,730 Once we open it again 103 00:05:29,730 --> 00:05:32,040 we can see all the folders and files 104 00:05:32,040 --> 00:05:36,660 inside of this /home/mrhacker directory. 105 00:05:36,660 --> 00:05:40,710 But we didn't see these files inside of our Terminal. 106 00:05:40,710 --> 00:05:41,880 So how can we list them? 107 00:05:41,880 --> 00:05:45,270 How can we see all of these files using Terminal 108 00:05:45,270 --> 00:05:47,970 so we know which directories are available 109 00:05:47,970 --> 00:05:52,140 inside of this /home/mrhacker directory? 110 00:05:52,140 --> 00:05:55,260 To check files and folders in any directory 111 00:05:55,260 --> 00:05:58,923 we can use another familiar command which is ls. 112 00:05:59,850 --> 00:06:02,220 And the ls command stands for list. 113 00:06:02,220 --> 00:06:03,633 So let's just test it out. 114 00:06:05,370 --> 00:06:07,620 If we type it, press Enter. 115 00:06:07,620 --> 00:06:11,130 Here we are, we can see same folders 116 00:06:11,130 --> 00:06:14,220 and same files that we can see inside 117 00:06:14,220 --> 00:06:15,520 of this window right here. 118 00:06:16,950 --> 00:06:19,710 So what we did for now is we used Terminal 119 00:06:19,710 --> 00:06:24,210 instead of clicking on bunch of files, bunch of icons, 120 00:06:24,210 --> 00:06:28,350 we now are doing all of that with our Terminal. 121 00:06:28,350 --> 00:06:33,060 Now that we know which folders are in this directory 122 00:06:33,060 --> 00:06:35,310 we can choose which folder we want to go to 123 00:06:35,310 --> 00:06:37,353 and use cd command to go there. 124 00:06:38,670 --> 00:06:43,670 But let us go one directory back from the /home/mrhacker. 125 00:06:44,400 --> 00:06:47,853 To do that we already know we can type cd and then two dots. 126 00:06:49,560 --> 00:06:52,680 And by the way, cd simply stands for changing directory, 127 00:06:52,680 --> 00:06:56,193 don't know if I mentioned it but cd is changing directory. 128 00:06:57,210 --> 00:07:00,600 And now we can see once we went one directory back 129 00:07:00,600 --> 00:07:02,643 we are in /home directory. 130 00:07:03,510 --> 00:07:05,103 If we type ls here, 131 00:07:06,330 --> 00:07:09,300 we can see here is our mrhacker directory 132 00:07:09,300 --> 00:07:12,153 that is containing these files right here. 133 00:07:13,050 --> 00:07:14,700 Since we went one step back, 134 00:07:14,700 --> 00:07:17,610 we can only see mrhacker directory 135 00:07:17,610 --> 00:07:19,290 since this is the only folder 136 00:07:19,290 --> 00:07:21,393 inside of this /home directory. 137 00:07:22,260 --> 00:07:24,273 Let's go one more step back. 138 00:07:25,140 --> 00:07:28,380 If I type cd two dots once again, 139 00:07:28,380 --> 00:07:33,380 now I'm in /directory and it is called /directory 140 00:07:33,480 --> 00:07:37,900 because it is only specified as a forward slash 141 00:07:39,150 --> 00:07:41,460 and we can go more than that. 142 00:07:41,460 --> 00:07:42,930 This is the main directory 143 00:07:42,930 --> 00:07:45,930 that has all of the other files and directories 144 00:07:45,930 --> 00:07:46,763 in the system. 145 00:07:47,610 --> 00:07:49,570 If we try to type cd once again 146 00:07:50,820 --> 00:07:54,720 you will see it'll still be in the /directory. 147 00:07:54,720 --> 00:07:58,260 And remember when I told you during Kali Linux installation 148 00:07:58,260 --> 00:08:03,240 that we will shortly see /home/tmp/vardirectories 149 00:08:03,240 --> 00:08:06,180 that occurred in one of the installation questions. 150 00:08:06,180 --> 00:08:10,683 Well, if I type ls right here, here they are. 151 00:08:11,550 --> 00:08:14,250 These are all just standard Linux directories, 152 00:08:14,250 --> 00:08:17,163 and here is /home from which we came from, 153 00:08:18,630 --> 00:08:22,983 here is /var, and here is tmp, 154 00:08:24,120 --> 00:08:26,100 and bunch of other directories 155 00:08:26,100 --> 00:08:29,823 and these are all just standard Linux directories. 156 00:08:31,170 --> 00:08:35,342 From here you will notice that not all of it is same color. 157 00:08:36,210 --> 00:08:38,820 This is because not all of the stuff we see here 158 00:08:38,820 --> 00:08:40,440 is the same thing. 159 00:08:40,440 --> 00:08:43,679 Something is a directory, something is a file. 160 00:08:43,679 --> 00:08:48,390 And for example, we cannot use cd command onto a file. 161 00:08:48,390 --> 00:08:52,050 We can only use cd to go to another directory. 162 00:08:52,050 --> 00:08:57,050 So if we try, for example, cd and I choose this file, 163 00:08:57,210 --> 00:09:02,210 so cd initrd.img and press Enter, 164 00:09:05,820 --> 00:09:07,320 this will not work. 165 00:09:07,320 --> 00:09:09,993 It'll give us an error saying not a directory. 166 00:09:10,980 --> 00:09:14,220 But if we type cd and then etc for example, 167 00:09:14,220 --> 00:09:17,490 which is this directory, and press Enter, 168 00:09:17,490 --> 00:09:20,133 now I will be inside the etc directory. 169 00:09:21,000 --> 00:09:22,800 And here I can type ls 170 00:09:22,800 --> 00:09:26,130 to list all of the files inside of the etc directory, 171 00:09:26,130 --> 00:09:27,510 and you will also notice 172 00:09:27,510 --> 00:09:32,190 that here we got a mixture of files and directories as well. 173 00:09:32,190 --> 00:09:35,343 Directories are these dark blue names, 174 00:09:36,390 --> 00:09:40,503 while files can be other colors depending on file type. 175 00:09:41,400 --> 00:09:42,873 Usually they're white. 176 00:09:44,520 --> 00:09:45,720 Okay, great. 177 00:09:45,720 --> 00:09:48,450 We'll learn the basics of navigating through Linux system 178 00:09:48,450 --> 00:09:51,300 and directories using different commands. 179 00:09:51,300 --> 00:09:54,573 Now, before we finish this video, here is a practice test. 180 00:09:55,440 --> 00:09:58,620 Try returning to the desktop directory 181 00:09:58,620 --> 00:10:02,400 from this etc directory using only the commands 182 00:10:02,400 --> 00:10:03,273 that we learned. 183 00:10:04,110 --> 00:10:06,060 I will give you right now a few seconds 184 00:10:06,060 --> 00:10:08,103 and I will show you how to do it. 185 00:10:09,000 --> 00:10:10,293 So try it out. 186 00:10:15,000 --> 00:10:15,833 Okay. 187 00:10:15,833 --> 00:10:17,550 Don't worry if you didn't get it, 188 00:10:17,550 --> 00:10:19,260 this will come with practice. 189 00:10:19,260 --> 00:10:20,853 So here it is how we can do it. 190 00:10:21,720 --> 00:10:23,370 From the etc directory, 191 00:10:23,370 --> 00:10:28,370 we know that we must go back to the /directory. 192 00:10:29,610 --> 00:10:34,080 And in this /directory we got our home directory. 193 00:10:34,080 --> 00:10:36,810 We can check it out by typing ls. 194 00:10:36,810 --> 00:10:38,970 And inside of this home directory 195 00:10:38,970 --> 00:10:41,250 we know that we got the mrhacker directory, 196 00:10:41,250 --> 00:10:45,360 and the mrhacker directory has the desktop directory. 197 00:10:45,360 --> 00:10:48,003 So to navigate there we can type cd home, 198 00:10:49,230 --> 00:10:53,403 type ls here, then type cd mrhacker, 199 00:10:54,330 --> 00:10:56,010 type ls here once again 200 00:10:56,010 --> 00:10:58,290 to check out all of the available directories 201 00:10:58,290 --> 00:11:00,363 and cd desktop. 202 00:11:01,650 --> 00:11:05,640 And now we are on our desktop directory once again. 203 00:11:05,640 --> 00:11:09,420 Great. So practice a little bit with these commands. 204 00:11:09,420 --> 00:11:10,830 This is nothing really too hard. 205 00:11:10,830 --> 00:11:12,030 Just take some practice 206 00:11:12,030 --> 00:11:14,850 and you will get used to it pretty soon. 207 00:11:14,850 --> 00:11:17,040 And in the next video we're going to see 208 00:11:17,040 --> 00:11:20,970 how we can create files and folders using Terminal, 209 00:11:20,970 --> 00:11:24,453 as well as we are going to see how we can run programs. 210 00:11:25,320 --> 00:11:26,153 See you there.