Creating files and directories in this lesson, we will cover how we can create files and directories,
different ways to create files.
The first one is the touch.
The touch command creates a file that is, of course, an empty file.
The second way to create a file is if you are copying an existing file and creating a new file at the
destination location.
And the third way to create a file is through VII Command No.
VII is our editor, which we will cover in detail later in the lessons.
But I will cover quickly how we could create a file using VII creating directories.
The easiest way to create directory in the command is Ms.
Kadeer, which is make directory.
So now let's get into our Linux machine and we will use every command listed here as a practice to create
a files.
OK?
The first thing we have to do is to find out what user ID we are logged in as so you do, who am I and
would tell you you are logged in as yourself?
And then the second thing you have to now which directory you are in, and I am in my home directory.
Now I will be creating a few files and as your homework, I want you to create those files and directories
as well.
The first way to create a file here is here.
I have a list of files that I will be creating.
We will use the first command to create a file will be touch, OK, touch space I have here.
Jerry, hit enter and you hit enter and you get the prompt back.
That means your command worked.
Now how do we know?
Where is that file?
You do Ellis minus L and you will see here the directory you have is right here.
Jerry.
Sorry, the not actually the file.
Now I want you to create another file.
Touch Kramer again, check if it's created.
Yes, it is created, Jerry and Kramer.
Now I use the option Ellis minus L, which will list all the files and the directories in alphabetical
order.
Now, if you wanted to list all the files or directories that are created that was last modified, you
will use LS minus L TR, which means give you everything by the timely order and in reverse, meaning
the oldest one of the top and the newest one at the bottom.
Then you hit enter.
You will see Jerry was the first one that was created, followed by the Kramer.
Next one we are creating is George.
How do you verify that file was created?
You do.
Ellis, L..
These files can be changed or renamed and moved.
But we'll go to the next set of files to create.
I want you to use this time to copy command, so I want you to use Copy and Jerry and then the destination
file.
I want you to be Lex to Ellis minus l tr.
So what exactly did it copied this Jerry file and named it Lex?
I want you to do the same thing for Clark.
So copy Jerry for Kramer, I which have a file and to Clark, same thing.
Copy Jerry and Lois.
Now let's verify we have all those files.
There you go.
We got all six files.
So now three files we created with Touch Command, three files we created with the copy command and
the rest of the files will create using VI.
Now remember, VI is a very tricky.
So I will only create one file and we will cover the violator.
So VII space homer, so hit enter.
Once you hit enter, it will bring you to file added to now.
Be very careful what you type in here because you will not be able to get out if you really don't know
what you are doing.
So at this point, I just want you to do shift colon w as in right.
Q. As in quite and exclamation point, which is also afoot as bank hit enter the file homer is created.
How do you verify verified the student s minus l tr?
And there you go, the homer file is created.
Now the other three files I will create by the touch command.
Now you will notice you don't have to run touch command over and over again.
You can run detach command just once and do like Space Lisa Space and Me or G March.
So now with this just one command, it will create three files.
So hit enter verified all three files.
Bart Mar, Lisa all of them are in this directory.
Now, the next step I want you to do is create directories within your home directory.
So just do pWt just to make sure you are in home directory.
Then from here you do m k d air space
filled.
Now the directory is created because you got you like a prompt back.
How do you provide a less mine cell TR?
And you see at the bottom that's where the directory is created.
And if you notice, some of the Linux distributions also change the color for use.
In this way, it will be easier for you to identify which one is the file or which one is a directory.
Same way I wanted to create another directory and or Superman.
And again, you could also do the same way instead of running one command after the other, you could
just run one command and followed by two different directories.
So the second, actually, we have a Simpson Simpson.
And hit enter.
Once you hit and Turkey into Alaska, minus L tr c, all three directories at the bottom and you have
all your files right here listed here.
So this is the way you create files and directories in your home directory.
If you try to create a directory in, let's say, slash or somewhere else where you do not have permission,
it would tell you that directory.
You do not have sufficient rights to create a directory.
So let's take the example if you go to CD, slash FC and I want to create a file here, let's call it
test one two three and hit enter going to tell you you do not have permission to create that file in
there because we don't loan Slash, who owns the slash route, owns it.
And you are not.
Who are you?
You are yourself.
In this case, I have salt again, and we learned three four commands Touch Copy VII to create files.
And the last command we learned to create directories is MacDill Air.