Instructor: Welcome back.
Here we are in our Kali Linux machine
and it is time we finally learn
how to use that mysterious tool
that is set to be the most important tool
that we must master.
Don't worry, Terminal is not difficult to use.
But before we get to open it and run bunch of the commands
let us first define what Terminal is.
So what is it?
Terminal is a program that allows us to interact
with Linux operating system using different commands.
We can create files, delete files, create directories,
run programs, set different tasks to execute,
and we can do many more things using it.
It is important you get used to it
especially if you never used it before,
because if you're coming from Windows or Mac OS
you probably are used to opening files or folders
by clicking on different icons and navigating like that.
For example, on Windows we usually open files
by double clicking on an icon and it'll open that folder.
And on Linux we can actually do the same thing.
So if I go right here and for example
I want to open this home folder
I will double click on that folder
and it'll open the folder with all the files inside of it.
But we don't want to be doing it like that.
Let us see how we can do it using Terminal.
So let us close this first
and we already know how to open Terminal,
right click on desktop and click open Terminal here.
First thing that we notice is username
that we have right here
and the host name that we have right here.
But we also noticed this /desktop.
This means that our Terminal process
has opened inside of the desktop directory.
Does it always open there?
Nope, it only opened there because we told it to open there.
Remember, we right clicked on desktop
and clicked open Terminal here.
If we, for example, went to the home folder
and right clicked here, open Terminal,
it doesn't say /home like it did in desktop.
It just gives us this way minus sign.
Well that sign in Linux
means that you are in your home directory of your user.
And our user is called mrhacker,
so the directory name should be /home/mrhacker.
And to check the directory name
we can type the command pwd.
If we press Enter, it'll give us the current directory
in which our Terminal process is running
and it is /home/mrhacker.
And this pwd simply just stands for print working directory.
If we for example, go to the folder once again
which is /home folder /mrhacker,
and we double click on documents,
try to open Terminal here.
So open Terminal here.
This will open a second Terminal
and you will see right here that it says /documents.
But do we always need to go to that folder
and open Terminal inside of that folder
for it to be inside of this directory?
Of course, not.
We can use a command called cd.
And you should be familiar with this command
since we already used it before.
Let us test it out.
Let's go to the documents directory from our home directory.
So I'll just close the second Terminal
and right here we are inside of our home directory,
or /home/mrhacker.
We know that inside of this directory
there is a documents directory
since we managed to open it right here.
And to navigate to this directory using Terminal
we can use the command cd
and then the name of the directory, which is documents.
We press Enter and here it is,
we are in /documents directory.
If we type pwd here,
it'll tell us the current working directory
is /home/mrhacker/documents.
And for example,
if we wanted to go one step or one directory back
we can type the command cd and then two dots.
What this command will do is it'll go one directory back
and if I type pwd once again,
we will now be again in /home/mrhacker directory.
So these two dots tell the Terminal
to go one directory back.
Okay, great.
But how can we know which subdirectories
and files are in home directory, for example?
If we knew there was documents directory in home folder,
because we opened it right here,
we didn't open it over Terminal
we opened it right here from our desktop.
Once we open it again
we can see all the folders and files
inside of this /home/mrhacker directory.
But we didn't see these files inside of our Terminal.
So how can we list them?
How can we see all of these files using Terminal
so we know which directories are available
inside of this /home/mrhacker directory?
To check files and folders in any directory
we can use another familiar command which is ls.
And the ls command stands for list.
So let's just test it out.
If we type it, press Enter.
Here we are, we can see same folders
and same files that we can see inside
of this window right here.
So what we did for now is we used Terminal
instead of clicking on bunch of files, bunch of icons,
we now are doing all of that with our Terminal.
Now that we know which folders are in this directory
we can choose which folder we want to go to
and use cd command to go there.
But let us go one directory back from the /home/mrhacker.
To do that we already know we can type cd and then two dots.
And by the way, cd simply stands for changing directory,
don't know if I mentioned it but cd is changing directory.
And now we can see once we went one directory back
we are in /home directory.
If we type ls here,
we can see here is our mrhacker directory
that is containing these files right here.
Since we went one step back,
we can only see mrhacker directory
since this is the only folder
inside of this /home directory.
Let's go one more step back.
If I type cd two dots once again,
now I'm in /directory and it is called /directory
because it is only specified as a forward slash
and we can go more than that.
This is the main directory
that has all of the other files and directories
in the system.
If we try to type cd once again
you will see it'll still be in the /directory.
And remember when I told you during Kali Linux installation
that we will shortly see /home/tmp/vardirectories
that occurred in one of the installation questions.
Well, if I type ls right here, here they are.
These are all just standard Linux directories,
and here is /home from which we came from,
here is /var, and here is tmp,
and bunch of other directories
and these are all just standard Linux directories.
From here you will notice that not all of it is same color.
This is because not all of the stuff we see here
is the same thing.
Something is a directory, something is a file.
And for example, we cannot use cd command onto a file.
We can only use cd to go to another directory.
So if we try, for example, cd and I choose this file,
so cd initrd.img and press Enter,
this will not work.
It'll give us an error saying not a directory.
But if we type cd and then etc for example,
which is this directory, and press Enter,
now I will be inside the etc directory.
And here I can type ls
to list all of the files inside of the etc directory,
and you will also notice
that here we got a mixture of files and directories as well.
Directories are these dark blue names,
while files can be other colors depending on file type.
Usually they're white.
Okay, great.
We'll learn the basics of navigating through Linux system
and directories using different commands.
Now, before we finish this video, here is a practice test.
Try returning to the desktop directory
from this etc directory using only the commands
that we learned.
I will give you right now a few seconds
and I will show you how to do it.
So try it out.
Okay.
Don't worry if you didn't get it,
this will come with practice.
So here it is how we can do it.
From the etc directory,
we know that we must go back to the /directory.
And in this /directory we got our home directory.
We can check it out by typing ls.
And inside of this home directory
we know that we got the mrhacker directory,
and the mrhacker directory has the desktop directory.
So to navigate there we can type cd home,
type ls here, then type cd mrhacker,
type ls here once again
to check out all of the available directories
and cd desktop.
And now we are on our desktop directory once again.
Great. So practice a little bit with these commands.
This is nothing really too hard.
Just take some practice
and you will get used to it pretty soon.
And in the next video we're going to see
how we can create files and folders using Terminal,
as well as we are going to see how we can run programs.
See you there.