In this video we'll discuss some essentials for working with directories.
So CD is what you use to change directory and MKDIR allows you to create a new directory.
If you use MKDIR P, you can create an entire new directory path,
as in MKDIR P my new files without a P it would fill
and with a P you create the entire path and then rmdir.
Well, in fact, RMDIR is a useless command. It removes the directory, but it only works if the
directory is empty. Better use RM RF because that also works if there is files in the directory.
Let's check it out.
I'm starting by using CD without any arguments. Did you notice what happens?
It brings me to my home directory and that is what CD without arguments is always doing.
I want to be in my home directory because otherwise I don't have any write permissions.
Now I'm going to use an MKDIR data and. Oh boy,
what is happening here? Well, we have a permission denied.
That's because the only location where as an ordinary user I can create files is in my home directory.
If I really wanted to create this directory data, I need to put sudo in front of it.
So then I need to enter my sudo password and now it is created. Let's
check it out using LS LD data and there we can see that it exists.
Now in fact, I don't want to have this directory data, so I'm using RMDIR
and that is even working because I did not create any files in there.
Now how about MKDIR files? Data that doesn't work for the simple reason that I'm trying
to create directory data in the directory files, but the directory files does not exist.
Simple solution, add P to it and that will create the entire directory path.
That's about all that you need to know for now about working with directories.