Hello and welcome.
So in this lesson, we are going to learn about some of
the Linux file and directory commands.
Now. These are the most important ones
and you're going to use this very very
frequently.
So let's quickly begin with the First Command, which is
the ls command.
So LS stands for list. So let
us see if I type the command LS and hit enter. What
is the output that we get?
You will be able to see whatever the content is there
into your computer. So basically all the
files and folders which are the directories
as you can see. These are all the files and folders that
are into my computer.
Alright, so if you want to see all the files in
a long listing, which is basically also known
as in detailed format, so
we are going to type the command, which is LS space hyphen
all
And you will be able to see this is the detailed listing
of a file in which you
are able to see more information about that file.
For instance just to make a difference if
it is a file or a folder.
By that I mean if it is a directory, you can
also see from here. For example, you can
see this file, which is you want. This is
a file. How do I know that?
And this UFO net is a folder, which is
a directory. How do I know that you can see here?
It is written D. So the file permission.
These are the file permissions and
here you can see a d which denotes that
this is a directory, which means it is a folder
and you want is a
file because there is no D. So this is one of
the way to identify files and folders in
Linux. Obviously, you can obviously make
out through this color coding but this is not the
best way to identify if this are files
are folders.
In the Linux operating system, so you can
type the command LS space hyphen a
l or hyphen a ll and you
will be able to see the detailed output of
that file from that you can make a difference if it
is a file or folder with a lot of more information as
well as you can see over here.
Which also gives you the information of which is
the user which has created the group the
size as well as the date.
When the file was successfully created.
Perfect. Let's move ahead. The next command that
we are going to see is PWD. So PWD
stands for present working directory. Now,
this will show you in which the
current directory you are. So I'm
currently working into a directory which is
slash route. Perfect. So let's
quickly navigate into a directory for that. We use
the command which is CD which stands for
change directory.
So let's change into a directory. And as we
saw UFO net is a directory because
we saw there was a D in front of that.
So let's go into this directory. And now
you can see we have successfully navigated into
this directory, which is UFO net.
Also, you can verify that using the
command which is PWD and hit enter and
you can see the present working directory is
slash root slash UFO net.
Perfect. So let's create a directory over here now to
create a new directory. You have to
type the command which is mkdir with
stands for make directory. So
let's quickly make a directory with the name as Rohit and
hit enter.
and you can see
there is no output which has displayed onto the
screen.
But a directory has been successfully created. Let's verify
using the command LS and you can
see here the name which is Rohit.
Okay, so far we have been doing
correct. So let's quickly go into that directory, which is
CD Rohit. And obviously we have
created the directory just now therefore the
directory is empty. Let's verify using
the command which is LS and you
can see no output over here. So let's quickly
create a file. So to create empty file
you can use the command which is touch.
So basically you are touching a file and creating a
empty file. So let's say touch one and
hit enter.
Now let's verify if we have created a
file. So let's type the command LS and
you can see there is a file which is
one but this file is currently
empty. So let's write some content
into this file. So for that there are different ways
to write content into a fight and different
editors which you can use so I'm going to use a
editor which is nano. So I'm just going to type the
command which is nano space the file name in
which you want to make changes. So Nano
space one and hit enter and this
is how it looks like so just remember
this is like your simple notepad editor
in which you can write something. So let's
quickly write. This is my
first
file and let's save this for that you
can simply type control s and you can
see it says root one line, press control X.
To come out of that file again. Let's go
inside that file, press Ctrl s to
save control X to come out of
that file.
Now as we have created a file.
Empty file and then we have written content into
that file. Let's try to verify if we have
written something into that or no.
So for that we are going to use the command which is
cat and hit enter.
And you can see the output of the command
cat is this is my first
file and this is what we wrote into
that file, correct?
Perfect. Now let me clear the screen for you and here
you can see we have one file. So
let's make a copy of this file. So
for that we have to type the command, which is CP.
And the file that you want to copy, so
we want to copy the file, which is one perfect.
Now if I hit enter
you can see we get a error it says missing
destination because we have
not specified where we want to paste the file.
We have just specified the source.
so
where do we need to paste the file? Let's make
a folder so mkdir
and let's make a folder named
as shifa and hit enter and you
can see here. We have a directory which is
shifa and we have a file which is one.
Let's make one more directory called as Sabah and
hit enter now we have a
file which is one.
Which has the content. This is my first file
and we have to empty directories. So
let's quickly copy the file one into shifa
and hit enter.
And you can see here is the file and there should
be a file inside the directory, which is she far.
So, let's quickly go into the directory by the
command CD.
space the directory in which I want to
navigate and hit enter and
Let's check the present working directory. Yes, we are
into the directory, which is shifa. Let's verify if there
is a file and yes, there is a file. Let's verify
the content. It should be the same that we have created
and you can see it is exactly the
same content with says this is my
first file.
awesome
So let's go back.
By the command which is CD dot dot. So when you
type the command CD dot dot we are going to go
one step back. So currently we are into this directory shifa
and when we hit enter
we should be able to navigate one step
back into this directory, which is Rohit.
So let me hit enter and you can see now. I'm
into this directory which is Rohit.
Okay, perfect. So now we have created
a file inside the directory which
is shifa. So basically we have copied it.
Now. Let's try to delete this file, which
is one. So for that the command is RM which
stands for remove. So remove one
hit enter.
And you can see the file has been successfully removed.
Let's quickly remove a directory as well. So
let's say we remove the directory which is Sabah. So
RM space Sabah and hit enter.
And you can see it gave an error. It
says it's a directory. Okay, so we
cannot remove a directory by simply typing the
command RM. So let's remove the
directory with the command, which is RM dir.
So RM to
delete a file RM dir to remove
a directory and let's hit enter and you
can see we got no error and we have successfully deleted
the directory.
And you can see there is no one there is no
subah so let's delete the shifa
directory as well. So we have used
the command which is rmdir and let's
type the name shifa and hit enter.
Now this time we got a different error. It says
the directory, not empty. Perfect. So
now we came to know that we cannot delete
a directory which has something inside
it with the command rmdir rmdir
is only used to
delete empty directories. Perfect.
So, how do we actually delete this now? It's
very simple RM space hyphen r
f and we want
to delete the directory which is shifa. So remove
recursively forcefully whatever you
want to remove you can remove a file you can
remove empty directory or you can delete a
directory which has content inside it using
this command which is RM space hyphen RF.
Let's hit enter and you can
see it's gone. Everything is deleted from here.
So I hope you guys understood how you can use
this command.
Alright, so this is it for this video. Let's go ahead and
see you into the next lesson. Thank you.