One of the things that we as penetration testers need to know is navigating through the system with
the help of a command line.
Now, this is a prerequisite that we're going to cover.
So if you're already familiar with Linux and terminal commands, feel free to skip these few lectures
that will devote to it.
OK, now, for those of you who are not familiar with terminal, you are probably wondering why do we
need to learn this?
What is the purpose of using a command line?
Well, terminal, as we already mentioned, is a command line interface that allows us to control and
navigate through the system.
It isn't graphical user interface, so it's rather simple.
You type in a command and you get the output in Linux systems.
It's called terminal, while in Windows Systems, it's called command prompt.
Now, one of the reasons why this is important for us is when you gain access to the target during your
penetration test, you won't really get a desktop access to it.
You won't be able to see all the icons, the programs, its desktop.
None of those things will be visible to us.
Instead, who will control their system with the command line to by running different commands.
With time, you will start using terminal more and more and you will get better and better.
But for the purposes of discourse, we're just going to cover some basic commands in this section.
And we'll also learn a couple more advanced commands during the course.
So let's start by checking how we can open the terminal inside of our Linux machine.
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
and this icon right here is actually terminal, as you can see right here.
It says terminal emulator.
If I click on it, it will open the terminal to.
Here it is now.
There are a few things that we can see right here.
We can see the name of our account that we created during the installation of clinics.
And we can see the path right here in the brackets and this is the path in the system.
Now, before we run, any comment right here, let me just explain this path a little bit more just
so we can fully understand it.
So I'm going to close the terminal right here.
And that path that you saw depends on where you open the terminal.
For example.
I can also go on my desktop, right.
Click and go open terminal here.
You will notice we will open everything that looks the same except this path.
We open terminal in slash desktop directory.
And you can do this in any folder that you want.
You can go in home directory open terminal where you can go and download directory documents directory.
And the path to that directory will be written in these square brackets right here.
OK, another way that you can check the full path to the rectory that the terminal is opened in is by
typing the command p w the.
If I press enter, it will give me the full path to the desktop directory, which is slash home, slash
Mr. Hacker and slash desktop.
Now, to see the contents of the directory that you're inside, you can type the command out and you
will notice once they type this command, it will be an empty list since there are no files or folders
in the desktop directory.
But this doesn't mean that all the other directories are also empty.
For example, we can also open another terminal, which will be in this directory right here and not
in desktop directory.
And if I type Altez here, well, now we get some response back.
We get a list of other subdirectories that are inside of this directory right here.
And we also get the test of the rectory so we can conclude that this that's the directory that we are
inside in this first terminal is actually a subdirectory of Mr. Hekker.
Now to navigate inside the one terminal between multiple directories, we can use a comment and let
me just show you right here.
So I'm going to close this one.
Let's go back to the one that is in the desktop directory, and we can use the command CD and then,
for example, Egholm.
You won't notice instantly that the path changes, we're no longer inside the desktop, we are in home
and we can prove it by typing, which will tell us the directory name.
By the way, if I didn't mention PWP stands for Print Working Directory.
Now, if you type here, what we get only one response, which is Mr. Hacker, so how can we go to this
Mr. Hack directory?
Well, we can also use CD and then Mr. Hacker.
And we're back to Mr. Hacker directory, if I type, as you will see, an already familiar response.
OK, but how can we go one directory back, for example, let's say we are currently in Mr. Akeda rectory
and we want to go back to the home directory without having to type CD.
And then let's say we don't know what is the directory name and we want to go one directory back what
we can do by typing a CD and then two dots.
If I press enter, you can see that we're currently back in my home directory.
So the command CD and then two dots actually puts us one directory back.
OK, also, now that we know these comments, let's navigate to slash home, slash Mr. Hacker and then
let's go to the desktop directory of Mr. Hacker.
Now, let's cover a new command, a command that will allow us to create files that command is called
Touch Now Touch creates empty files and all we need to do to create an empty file is titled Touch.
And then the file name.
Let's call it file one.
If I type out again and remember, this is a command that will list all the files and directories inside
of the current working directory.
Now we get the response, we have a file, one inside of our desktop directory, and even if I go and
lower this terminal, you will see the file one on our desktop.
So we successfully created it.
Now, the same way that we can create files, we can also create folders.
The command to create the folder would be mkdir, which stands for the rectory folder one.
Now keep in mind this file one and folder one you can name anything like this is just a name that you
give to your file slash directory.
And if I type mkdir folder one.
I lower my terminal now we have folder one on our desktop, and we will also see if I type as as we
can see, we have file one and folder one.
Another useful comment would be to copy files, so let's say we want to copy this file one.
Inside the folder one, how can we do that?
Well, we use the command CB and it works like this.
We type.
And then the file that we want to copy and then the location where we want to copy it.
In our case, we can specify zip file one, two, folder one.
Now, we don't need to specify the full path folder one because the folder one is already in slash desktop
directory.
But if folder one was in some other directory, we will have to specify the full path to it in order
for this file to be copied to the correct location.
So let's press enter.
If I type less, we will still have file one in our test directory.
But if we also said to folder one directory and type less, well, we have file one in folder one directory
as well, so we successfully copied it now compared to the copy command.
We also have the move command.
It does the same thing, just it doesn't copy.
It simply just moves the file from one location to another.
So once you use the move command, the file will no longer be in the first location that it was at,
whether it will be in the location that you moved it to.
So let's see how that works.
Let's say now we want to move the file one from the folder one to the home directory.
We can do that by typing M.V., which stands for MOV File one and then two slash home directory.
If I press enter.
Hmm.
It gives me permission denied.
Now, permission denied is something that we will talk about in the next lecture from now on.
Let's just forget it and we will get to it in the next lecture.
Let's just change the path where we want to move our file one so we can type move file one to slash
home slash Mr Packer.
OK, this one worked.
We didn't get any error that says permission denied.
So now let's see whether we first have the file inside the folder.
One if I type, unless you will notice that our file is no longer here.
So we moved it.
Now let's see whether we moved it to the correct location.
We can copy this location and type CD.
And then.
Home slash, Mr. Hacker, if I type here, well, here is our file one, we successfully moved it to
this home slash Mr. Hacker directory.
Now, another interesting comment that we can use is called Acco.
If I type Akko and I type, for example, hello world like this.
So Eckle open double quotes.
Hello World and then close the records.
It will just print out hello world inside of our terminal.
But if I do something like this echo hello world, and then I use double arrow to the right and then
our one.
Well, we don't really get anything printed out, but what did we do right here?
Well, in this comment actually used this drink and we put it inside of one.
So now file one is no longer an empty file.
It contains this text.
How can we check it out?
Well, we can check out what are the contents of that one with the help of another comment.
And that comment is called Cat.
So Cat File one will print out the contents of the file.
If I press it.
Here it is.
We can see the content of one which says Hello World.
Now you can also check the contents by going and visiting file one like this, even though it will be
empty because we actually inputted our strength in file one in slash home, slash Mr. Hacker directory
and not in the rectory.
But nonetheless, you can also enter something here if you want.
But it's important to get used to using terminal instead to do these simple tasks.
So now that we learned how we can create temp defaults, how we can write things in empty files, and
how we can actually switch between different directories, how we can copy files, more files and all
of that, let's also see how we can delete files.
For example, we're in our home slash Mr. Hacker directly and we can confirm that once again by typing
PWP.
And let's say we want to remove this file.
One, we no longer need it, so let's just remove it.
We can use the command M and after the our moment comes the file name.
See type are and for one press enter and then Kalpesh again.
We no longer have one in this directory, however, we do still have it inside of our desktop directory,
so let's delete it here as well.
To go to that store directly, I can type CD slash home, slash Mr. Hacker slash desktop if I type,
unless we have one enfold or one and I can type remove one or R.M. if I want.
Let's also try to do that with FALDER one, if I type Freimuth, for one, we get an error, cannot
remove all or one it is a directory.
So how can we remove directories?
Well, instead of just typing R.M. and then the directory name, we can type our M folder one.
And then at the end we add that part.
With this command we can remove a directory.
If you notice, when I type URLs, we no longer have one or folder one.
OK, I hope you understood all of this.
Now, don't worry if this seems a little bit confusing to you, make sure that you practice these commands,
make sure that you practice navigating with the command, creating files, deleting files, copying
files and all of that.
And in the next video will continue with some new commands that we can use inside of our terminal.
OK, awesome.
Soon the next video.