OK, so if we know how to find our way to the desired directory in terminal, but what if we need to
create a file or a subfolder in another directory, how can we do that?
Well, first, let's open up our terminal.
And by the way, another way that you can open terminal instead of.
Right.
Clicking and going open terminal here, he's going up here to this icon which says terminal emulator
and clicking on it.
By default, this will be inside of your home directory, which we know to be designed, and if we type
the public comment, we get slash home slash Mr. Hacker directory.
We know that our desktop directorate is also inside of this directory.
So let's go there, see the desktop press enter.
And now we are in the desktop directory.
Let's get back to the files to create a simple empty file, we can use a command called Touch if we
simply just type touch file and let's call it file one.
Press enter, this will create a file named file one, and it will have no contents inside of it.
We can also see that file one has been created as it is right now on our desktop since we created it
inside of this desktop directory.
And if we also type, unless we can see that the file is in our desktop directory to make sure this
file is indeed empty, we can use the command cat.
And this command, once executed on the file, writes out all the contents that are inside of that file.
Let's try it out so we specify CAT and then file one.
Press enter, and this will give no results since, as we already mentioned, the touch command creates
empty files.
If we want to, for example, put something inside of that file, we can use a command echo.
You simply just typed it like this echo.
And to put something you specify after the echo, let's say today is a really good day.
So we specified an entire sentence.
And all we need to do is to put this sentence inside of this file is to specify this arrow to the right.
And after it, specify the name of the file that we want to put this sentence in, so Echo today is
a really good day into the file.
One press enter and if we catch it once again with the cat comment.
So Cat fight one.
We will see that now it outputs exactly what we've written to that file using the Echo comment, OK,
that's all good.
But there is an easier way and more practical way to do all of this.
We can use a text editor to write things inside of a file and an easy text editor that we can run from
terminal is called Nannerl.
So let's try to do the same thing we just did using Nano.
If we type now and after nine 00 comes the name of the file that you want to edit, and since we want
to edit our new file that we haven't created yet, we can simply just type name let's call it file two
and press enter this will open this empty window where we can type anything we want.
We can type file content here and it can be anything we can type, for example, text here, but we
could also type code if we wanted to.
Let's start with text first.
Let's write just the World as a text.
To save this, we press control OAP together, then enter to save under this name and then control X
exit the NENO Ed.
If we know type cat and then filed to and by the way, we can notice that file too has been created
along file one on our desktop.
But if we can file to.
We can see the output of Hello World.
So we managed to do it only using one tool, which is now, instead of using two tools which are touch
and echo, but I also mentioned we can do the same thing with programs.
For example, how can we create Python program using nano and terminal?
First, we need to open a file, so let's type NENO and then file free dot vi.
And in this case we add dot p y because that is an extension for Python programs.
Then inside of it, after pressing enter, we're going to run a simple command, which is print.
And then hello, world between the quote.
And you will see that some stuff changes colors, this is because the Nano editor recognizes this as
a Python program.
What we did right here, in case you're not familiar with Python, is we just ran a simple function
that will print out the string that is in between the quote.
So this will just print out how world let's save it with control.
OK, then press enter and then control exit.
And luckily for us, Python is already installed in clinics.
So all we need to do to run this program is to type python free.
And then the name of the file file three dot by.
Press enter and the program will execute here it printed out.
Hello, world cool, right?
You will also notice that the icon is different than these two icons.
This is also, once again, because this is recognized as a python program.
It even has the Python icon.
Now that we know how to create false and execute Python programs, the next question would be how can
we create the rectories?
To create a directory, we can use the command mkdir, which stands for Make Directorate.
To check it out, let us front and Kadir and name of the rectory folder.
So press enter and if I type, yes, we will see that we got our files as well as a directory, which
is a different color and it is called folder.
Remember, we differentiate them by color and also if we try to change the rectory to the folder, it
will work.
It will even give us the path of slash desktop slash folder.
Great in that folder.
You can do pretty much anything you want.
You can create sub folders or create files, whatever you want to do.
You can to move, for example, our Python program from the desktop directory to our folder directory.
We can use Command and V, which stands for both.
We must first navigate back to that subdirectory.
Let's do it using CD and then two dots to go one directory back and from it we run the command and we
file three people into the folder.
So we specify move.
Then the second parameter is what we want to move, which in our case is file three, the P, and the
last parameter is where we want to move it.
We want to move it inside of our folder, suppress your enter and you will notice that the file tree,
that pie disappeared from our.
That's the directory.
We can also check that Taiping else and notice that our Python program is no longer here, but if we
go to the folder directory Antipolice here, we will see it here because we moved it.
Here it is file three that by now this is a handy comment and you will use it a lot besides moving the
file.
We also want to see how we can copy a file and we can do it using this comment.
This does the exact same thing as move command, but it doesn't move it from original directorate to
desired directory, it just copies it.
So let's try to copy file three that P y and call it file for that by.
If I typed CP, which stands for copy file three would be.
And I type file for that pie right after it.
This will create an exact copy of our file in the same directory if I press enter.
Type, here it is, we got filed three to three and filed for the pivo, if we want to change whether
they are exactly the same, we can catch the content of file three to three and get the content of file
for the copyright.
And we can see they're both the same Python programs.
And last comment that we want to cover regarding Falls is the command and.
This command deletes files and directories and let's say we try to delete files for the FBI, that is
our copy of our Python program.
We can do it by typing our name and then file for that by.
Now, be careful with this common sense, once you delete the file, there is no trash bin where you
can retrieve it, it is gone.
If I type enter antipolice, you will see our file for the P is no longer there.
OK, but how do we delete a directory?
Let's first create a directory inside of our folder directory, and to do that we type mkdir and let's
call it folder to folder to is a subdirectory of our folder if I type.
Here it is.
And let's say we did create this directory by mistake and we want to delete it, can we use our M folder
to.
Well, we can try it.
Hmm, cannot remove all or two, and it will tell us that it is a directory, so how do we delete it?
Well, we'll remove it in the same way we remove files.
We just add an option at the end of the comment.
So type our M folder, too, and then at the end, add space and then dash part.
Press enter and this will delete our directory also double check what you're deleting with this common
sense.
If you go to our directory, which is directory containing all folders and files in system, and if
we were to type, for example, in that directory, ah, and then the stop sign and then there are this
command for delete in park Linux machine with all of its files.
So always pay attention.
What exactly are you deleting in Linux and from which the rectory.
Are you deleting sins inside of the Linux.
You will not be stopped in deleting anything you want.
You can easily delete a crucial file for the operating system and make your clinic's machine unworkable.
That is also a reason why we are practicing with virtual machine.
So let's whoops, I actually ran this and you will notice that the results of this comment, if I type
ls now over folder is completely empty.
So I actually ran this by mistake.
And keep in mind, if I actually ran this from this directory, which is our route directly, I would
delete entire clinic system for now.
It is good since I only deleted our Python program, so it is not a big deal.
OK, great.
We learned a bunch of the commands in this lecture.
Now I got the practice test for you that you can try to do for the next lecture inside of our folder
directory since I deleted my Python program.
I want you to create the file trade API once again.
You can type anything you want inside of it.
You can use the print hello world statement that we used.
And what I want you to do using the commands you learned in this video is to copy that file in the desktop
directory from our folder directory.
So you created inside this directory and I want you to copy it back to the desktop directory.
A hint is that it can be a little tricky once you copy files from some directory to directory anyways,
just try it and we're going to see the solution in the next video.