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 LZ command.
So LZ 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.
All right.
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 or folders in the Linux operating system so you can type the command ls space hyphen
a l or hyphen a l l 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 P.W DX.
So PWT 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 our directory.
And as we saw, UFO net is a directory because we saw there was a DX 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 up for Nat.
Also you can verify that using the command which is p dx 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 D R, which 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 the 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 hit 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 an empty file you can use the command which is touch.
So basically you are touching a file and creating an 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 file and different editors which you can
use.
So I'm going to use an 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 us quickly write.
This is my first.
File.
And let's save this for that you can simply type control se and you can see it says route one line press
control X to come out of that file again, let's go inside that file.
Press control SW 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 an 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 r and let's make a folder named as shiffer 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 Saba 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 Shifa.
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 which says
This is my first file.
Awesome.
So let's go back.
By the command, which is CD.
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 R, 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 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 arm.
So let's remove the directory with the command, which is our m d i r.
So Aram to delete a file ah dear, 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
Sabah.
So let's delete the Shifa directory as well.
So we have used the command which is our MD here 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.
Ah mdi ah ah mdi ah.
Is only used to delete empty directories.
Perfect.
So how do we actually delete this now?
It's very simple.
I am 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 arm 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.
All right.
So this is it for this video.
Let's go ahead and see you into the next lesson.
Thank you.