1 00:00:01,020 --> 00:00:08,820 One of the things that we as penetration testers need to know is navigating through the system with 2 00:00:08,820 --> 00:00:10,200 the help of a command line. 3 00:00:11,160 --> 00:00:14,650 Now, this is a prerequisite that we're going to cover. 4 00:00:14,670 --> 00:00:20,730 So if you're already familiar with Linux and terminal commands, feel free to skip these few lectures 5 00:00:20,760 --> 00:00:22,200 that will devote to it. 6 00:00:23,160 --> 00:00:29,880 OK, now, for those of you who are not familiar with terminal, you are probably wondering why do we 7 00:00:29,880 --> 00:00:30,830 need to learn this? 8 00:00:31,440 --> 00:00:34,390 What is the purpose of using a command line? 9 00:00:35,410 --> 00:00:41,410 Well, terminal, as we already mentioned, is a command line interface that allows us to control and 10 00:00:41,410 --> 00:00:42,800 navigate through the system. 11 00:00:43,480 --> 00:00:47,050 It isn't graphical user interface, so it's rather simple. 12 00:00:47,380 --> 00:00:52,680 You type in a command and you get the output in Linux systems. 13 00:00:52,690 --> 00:00:57,430 It's called terminal, while in Windows Systems, it's called command prompt. 14 00:00:58,060 --> 00:01:04,330 Now, one of the reasons why this is important for us is when you gain access to the target during your 15 00:01:04,330 --> 00:01:09,220 penetration test, you won't really get a desktop access to it. 16 00:01:09,520 --> 00:01:13,780 You won't be able to see all the icons, the programs, its desktop. 17 00:01:14,050 --> 00:01:16,420 None of those things will be visible to us. 18 00:01:17,020 --> 00:01:22,120 Instead, who will control their system with the command line to by running different commands. 19 00:01:22,960 --> 00:01:27,930 With time, you will start using terminal more and more and you will get better and better. 20 00:01:28,240 --> 00:01:32,800 But for the purposes of discourse, we're just going to cover some basic commands in this section. 21 00:01:32,800 --> 00:01:36,330 And we'll also learn a couple more advanced commands during the course. 22 00:01:36,820 --> 00:01:42,360 So let's start by checking how we can open the terminal inside of our Linux machine. 23 00:01:43,380 --> 00:01:49,830 There are a couple of ways that we can do this, if we go up here, we're going to see a couple of icons 24 00:01:50,100 --> 00:01:55,500 and this icon right here is actually terminal, as you can see right here. 25 00:01:55,500 --> 00:01:57,440 It says terminal emulator. 26 00:01:58,140 --> 00:02:01,620 If I click on it, it will open the terminal to. 27 00:02:02,630 --> 00:02:04,290 Here it is now. 28 00:02:04,790 --> 00:02:06,600 There are a few things that we can see right here. 29 00:02:07,190 --> 00:02:12,590 We can see the name of our account that we created during the installation of clinics. 30 00:02:13,400 --> 00:02:18,500 And we can see the path right here in the brackets and this is the path in the system. 31 00:02:19,310 --> 00:02:25,400 Now, before we run, any comment right here, let me just explain this path a little bit more just 32 00:02:25,400 --> 00:02:26,950 so we can fully understand it. 33 00:02:27,140 --> 00:02:29,270 So I'm going to close the terminal right here. 34 00:02:29,480 --> 00:02:33,310 And that path that you saw depends on where you open the terminal. 35 00:02:33,560 --> 00:02:34,270 For example. 36 00:02:34,280 --> 00:02:37,010 I can also go on my desktop, right. 37 00:02:37,010 --> 00:02:40,040 Click and go open terminal here. 38 00:02:40,880 --> 00:02:45,770 You will notice we will open everything that looks the same except this path. 39 00:02:46,430 --> 00:02:50,030 We open terminal in slash desktop directory. 40 00:02:50,450 --> 00:02:52,790 And you can do this in any folder that you want. 41 00:02:52,790 --> 00:02:58,490 You can go in home directory open terminal where you can go and download directory documents directory. 42 00:02:58,700 --> 00:03:03,620 And the path to that directory will be written in these square brackets right here. 43 00:03:04,600 --> 00:03:10,750 OK, another way that you can check the full path to the rectory that the terminal is opened in is by 44 00:03:10,750 --> 00:03:13,430 typing the command p w the. 45 00:03:14,630 --> 00:03:20,710 If I press enter, it will give me the full path to the desktop directory, which is slash home, slash 46 00:03:20,720 --> 00:03:23,300 Mr. Hacker and slash desktop. 47 00:03:24,480 --> 00:03:32,520 Now, to see the contents of the directory that you're inside, you can type the command out and you 48 00:03:32,520 --> 00:03:39,630 will notice once they type this command, it will be an empty list since there are no files or folders 49 00:03:39,900 --> 00:03:41,130 in the desktop directory. 50 00:03:41,850 --> 00:03:45,400 But this doesn't mean that all the other directories are also empty. 51 00:03:45,420 --> 00:03:51,240 For example, we can also open another terminal, which will be in this directory right here and not 52 00:03:51,240 --> 00:03:52,290 in desktop directory. 53 00:03:52,650 --> 00:03:57,930 And if I type Altez here, well, now we get some response back. 54 00:03:58,170 --> 00:04:03,390 We get a list of other subdirectories that are inside of this directory right here. 55 00:04:03,930 --> 00:04:10,200 And we also get the test of the rectory so we can conclude that this that's the directory that we are 56 00:04:10,200 --> 00:04:15,660 inside in this first terminal is actually a subdirectory of Mr. Hekker. 57 00:04:16,959 --> 00:04:24,340 Now to navigate inside the one terminal between multiple directories, we can use a comment and let 58 00:04:24,340 --> 00:04:25,270 me just show you right here. 59 00:04:25,280 --> 00:04:26,570 So I'm going to close this one. 60 00:04:27,040 --> 00:04:33,310 Let's go back to the one that is in the desktop directory, and we can use the command CD and then, 61 00:04:33,310 --> 00:04:34,860 for example, Egholm. 62 00:04:37,110 --> 00:04:44,190 You won't notice instantly that the path changes, we're no longer inside the desktop, we are in home 63 00:04:44,400 --> 00:04:49,250 and we can prove it by typing, which will tell us the directory name. 64 00:04:49,590 --> 00:04:54,150 By the way, if I didn't mention PWP stands for Print Working Directory. 65 00:04:55,490 --> 00:05:02,630 Now, if you type here, what we get only one response, which is Mr. Hacker, so how can we go to this 66 00:05:02,630 --> 00:05:03,710 Mr. Hack directory? 67 00:05:04,220 --> 00:05:08,050 Well, we can also use CD and then Mr. Hacker. 68 00:05:09,700 --> 00:05:17,200 And we're back to Mr. Hacker directory, if I type, as you will see, an already familiar response. 69 00:05:18,300 --> 00:05:24,810 OK, but how can we go one directory back, for example, let's say we are currently in Mr. Akeda rectory 70 00:05:24,930 --> 00:05:29,500 and we want to go back to the home directory without having to type CD. 71 00:05:29,640 --> 00:05:37,440 And then let's say we don't know what is the directory name and we want to go one directory back what 72 00:05:37,500 --> 00:05:40,350 we can do by typing a CD and then two dots. 73 00:05:40,680 --> 00:05:45,870 If I press enter, you can see that we're currently back in my home directory. 74 00:05:46,350 --> 00:05:50,940 So the command CD and then two dots actually puts us one directory back. 75 00:05:51,920 --> 00:06:01,190 OK, also, now that we know these comments, let's navigate to slash home, slash Mr. Hacker and then 76 00:06:01,190 --> 00:06:04,330 let's go to the desktop directory of Mr. Hacker. 77 00:06:05,400 --> 00:06:12,840 Now, let's cover a new command, a command that will allow us to create files that command is called 78 00:06:13,020 --> 00:06:20,160 Touch Now Touch creates empty files and all we need to do to create an empty file is titled Touch. 79 00:06:20,160 --> 00:06:21,230 And then the file name. 80 00:06:21,240 --> 00:06:22,590 Let's call it file one. 81 00:06:23,670 --> 00:06:29,220 If I type out again and remember, this is a command that will list all the files and directories inside 82 00:06:29,220 --> 00:06:30,510 of the current working directory. 83 00:06:31,880 --> 00:06:37,970 Now we get the response, we have a file, one inside of our desktop directory, and even if I go and 84 00:06:37,970 --> 00:06:41,570 lower this terminal, you will see the file one on our desktop. 85 00:06:41,600 --> 00:06:43,360 So we successfully created it. 86 00:06:44,210 --> 00:06:48,440 Now, the same way that we can create files, we can also create folders. 87 00:06:49,400 --> 00:06:56,370 The command to create the folder would be mkdir, which stands for the rectory folder one. 88 00:06:56,930 --> 00:07:02,360 Now keep in mind this file one and folder one you can name anything like this is just a name that you 89 00:07:02,360 --> 00:07:04,100 give to your file slash directory. 90 00:07:04,970 --> 00:07:07,490 And if I type mkdir folder one. 91 00:07:08,570 --> 00:07:17,090 I lower my terminal now we have folder one on our desktop, and we will also see if I type as as we 92 00:07:17,090 --> 00:07:20,300 can see, we have file one and folder one. 93 00:07:21,140 --> 00:07:27,080 Another useful comment would be to copy files, so let's say we want to copy this file one. 94 00:07:28,010 --> 00:07:30,650 Inside the folder one, how can we do that? 95 00:07:30,830 --> 00:07:34,940 Well, we use the command CB and it works like this. 96 00:07:35,090 --> 00:07:35,570 We type. 97 00:07:36,230 --> 00:07:41,450 And then the file that we want to copy and then the location where we want to copy it. 98 00:07:41,660 --> 00:07:46,400 In our case, we can specify zip file one, two, folder one. 99 00:07:47,210 --> 00:07:52,940 Now, we don't need to specify the full path folder one because the folder one is already in slash desktop 100 00:07:52,940 --> 00:07:53,450 directory. 101 00:07:53,840 --> 00:07:59,720 But if folder one was in some other directory, we will have to specify the full path to it in order 102 00:07:59,720 --> 00:08:02,510 for this file to be copied to the correct location. 103 00:08:03,470 --> 00:08:04,940 So let's press enter. 104 00:08:05,330 --> 00:08:09,170 If I type less, we will still have file one in our test directory. 105 00:08:09,440 --> 00:08:17,420 But if we also said to folder one directory and type less, well, we have file one in folder one directory 106 00:08:17,420 --> 00:08:22,370 as well, so we successfully copied it now compared to the copy command. 107 00:08:22,400 --> 00:08:24,140 We also have the move command. 108 00:08:24,410 --> 00:08:27,080 It does the same thing, just it doesn't copy. 109 00:08:27,080 --> 00:08:30,320 It simply just moves the file from one location to another. 110 00:08:30,620 --> 00:08:35,690 So once you use the move command, the file will no longer be in the first location that it was at, 111 00:08:35,990 --> 00:08:38,730 whether it will be in the location that you moved it to. 112 00:08:39,020 --> 00:08:40,450 So let's see how that works. 113 00:08:40,850 --> 00:08:45,350 Let's say now we want to move the file one from the folder one to the home directory. 114 00:08:46,130 --> 00:08:54,320 We can do that by typing M.V., which stands for MOV File one and then two slash home directory. 115 00:08:55,010 --> 00:08:56,090 If I press enter. 116 00:08:56,990 --> 00:08:57,250 Hmm. 117 00:08:57,680 --> 00:08:59,390 It gives me permission denied. 118 00:08:59,660 --> 00:09:03,700 Now, permission denied is something that we will talk about in the next lecture from now on. 119 00:09:03,860 --> 00:09:07,010 Let's just forget it and we will get to it in the next lecture. 120 00:09:07,610 --> 00:09:13,550 Let's just change the path where we want to move our file one so we can type move file one to slash 121 00:09:13,550 --> 00:09:15,950 home slash Mr Packer. 122 00:09:17,300 --> 00:09:18,830 OK, this one worked. 123 00:09:18,830 --> 00:09:21,590 We didn't get any error that says permission denied. 124 00:09:21,840 --> 00:09:25,550 So now let's see whether we first have the file inside the folder. 125 00:09:25,550 --> 00:09:29,840 One if I type, unless you will notice that our file is no longer here. 126 00:09:30,260 --> 00:09:31,370 So we moved it. 127 00:09:31,580 --> 00:09:34,610 Now let's see whether we moved it to the correct location. 128 00:09:35,060 --> 00:09:37,730 We can copy this location and type CD. 129 00:09:38,740 --> 00:09:39,400 And then. 130 00:09:41,640 --> 00:09:49,290 Home slash, Mr. Hacker, if I type here, well, here is our file one, we successfully moved it to 131 00:09:49,290 --> 00:09:51,660 this home slash Mr. Hacker directory. 132 00:09:52,350 --> 00:09:57,110 Now, another interesting comment that we can use is called Acco. 133 00:09:57,820 --> 00:10:03,840 If I type Akko and I type, for example, hello world like this. 134 00:10:03,840 --> 00:10:05,850 So Eckle open double quotes. 135 00:10:05,850 --> 00:10:07,830 Hello World and then close the records. 136 00:10:08,910 --> 00:10:12,390 It will just print out hello world inside of our terminal. 137 00:10:13,290 --> 00:10:24,090 But if I do something like this echo hello world, and then I use double arrow to the right and then 138 00:10:24,090 --> 00:10:24,990 our one. 139 00:10:26,670 --> 00:10:31,360 Well, we don't really get anything printed out, but what did we do right here? 140 00:10:31,920 --> 00:10:38,450 Well, in this comment actually used this drink and we put it inside of one. 141 00:10:38,820 --> 00:10:42,060 So now file one is no longer an empty file. 142 00:10:42,240 --> 00:10:44,010 It contains this text. 143 00:10:44,430 --> 00:10:45,610 How can we check it out? 144 00:10:45,960 --> 00:10:50,730 Well, we can check out what are the contents of that one with the help of another comment. 145 00:10:51,060 --> 00:10:53,240 And that comment is called Cat. 146 00:10:53,940 --> 00:10:58,680 So Cat File one will print out the contents of the file. 147 00:10:59,160 --> 00:10:59,990 If I press it. 148 00:11:00,420 --> 00:11:01,050 Here it is. 149 00:11:01,620 --> 00:11:05,500 We can see the content of one which says Hello World. 150 00:11:06,420 --> 00:11:13,020 Now you can also check the contents by going and visiting file one like this, even though it will be 151 00:11:13,020 --> 00:11:18,600 empty because we actually inputted our strength in file one in slash home, slash Mr. Hacker directory 152 00:11:18,600 --> 00:11:20,460 and not in the rectory. 153 00:11:21,210 --> 00:11:24,990 But nonetheless, you can also enter something here if you want. 154 00:11:25,890 --> 00:11:32,270 But it's important to get used to using terminal instead to do these simple tasks. 155 00:11:33,150 --> 00:11:39,930 So now that we learned how we can create temp defaults, how we can write things in empty files, and 156 00:11:39,930 --> 00:11:46,170 how we can actually switch between different directories, how we can copy files, more files and all 157 00:11:46,170 --> 00:11:49,500 of that, let's also see how we can delete files. 158 00:11:49,950 --> 00:11:57,930 For example, we're in our home slash Mr. Hacker directly and we can confirm that once again by typing 159 00:11:57,940 --> 00:11:58,710 PWP. 160 00:11:59,130 --> 00:12:01,260 And let's say we want to remove this file. 161 00:12:01,260 --> 00:12:04,050 One, we no longer need it, so let's just remove it. 162 00:12:04,530 --> 00:12:10,200 We can use the command M and after the our moment comes the file name. 163 00:12:11,110 --> 00:12:16,150 See type are and for one press enter and then Kalpesh again. 164 00:12:17,110 --> 00:12:24,270 We no longer have one in this directory, however, we do still have it inside of our desktop directory, 165 00:12:24,730 --> 00:12:26,520 so let's delete it here as well. 166 00:12:27,650 --> 00:12:37,940 To go to that store directly, I can type CD slash home, slash Mr. Hacker slash desktop if I type, 167 00:12:37,940 --> 00:12:45,470 unless we have one enfold or one and I can type remove one or R.M. if I want. 168 00:12:46,470 --> 00:12:55,350 Let's also try to do that with FALDER one, if I type Freimuth, for one, we get an error, cannot 169 00:12:55,350 --> 00:12:57,750 remove all or one it is a directory. 170 00:12:58,470 --> 00:13:00,270 So how can we remove directories? 171 00:13:00,870 --> 00:13:07,350 Well, instead of just typing R.M. and then the directory name, we can type our M folder one. 172 00:13:07,350 --> 00:13:10,230 And then at the end we add that part. 173 00:13:11,310 --> 00:13:14,280 With this command we can remove a directory. 174 00:13:14,820 --> 00:13:20,720 If you notice, when I type URLs, we no longer have one or folder one. 175 00:13:21,770 --> 00:13:24,600 OK, I hope you understood all of this. 176 00:13:24,620 --> 00:13:29,690 Now, don't worry if this seems a little bit confusing to you, make sure that you practice these commands, 177 00:13:29,820 --> 00:13:35,810 make sure that you practice navigating with the command, creating files, deleting files, copying 178 00:13:35,810 --> 00:13:37,130 files and all of that. 179 00:13:37,130 --> 00:13:42,140 And in the next video will continue with some new commands that we can use inside of our terminal. 180 00:13:43,020 --> 00:13:43,700 OK, awesome. 181 00:13:44,180 --> 00:13:45,080 Soon the next video.