Computers in the past didn't have a graphical user interface as they have today.
So today we can use our mouse cursor, we can click on widgets, we can fill in text boxes, click on
buttons, etc. So what we use today is the graphical user interface of the operating system.
But back then, our ancestors, well, our older colleagues didn't have a graphical user interface.
All they had to was a C, L, a command line interface.
So they communicated with the computers using commands only text commands.
This command line interface, though, is still here in our computers.
So if you go to your start menu on Windows or Mac or Linux and search for CMD or terminal on Mac or
Linux.
So you should be able to open that same command line.
And in this command line you can navigate through your computer and you can still use your computer.
However, normally users don't really need to use this command line.
Nowadays.
The command line is only used by computer admins or programmers.
So as a programmer it is important for you to know the main commands that you can use on a command line
interface.
Why is that important?
Well, because sometimes, for example, we used the Heroku servers to deploy a web app.
Now Heroku is a server, so we don't have access to its graphical user interface.
We only have access to its command line interface.
So if you want to deploy your apps, your programs, your your code to a remote server, the only option
you have is to control that remote server through the command line interface.
That's why in this video I'll teach you how to use a command line interface.
So if you are on windows, please close the window command prompt and you should open the git bash.
So I assume you have installed git already.
If not, please search for git download on google.
Go to the first page downloads and then go to windows.
So download for windows and that should download either a 32 bit or a 64 bit git executable.
So then you should install that executable.
Just click on next, next.
Next.
If you have troubles, you can look at the programming tool lecture in day 15.
There is where I showed you how to install it, so I have installed git already.
So once you install git then you can search for git bash and open that.
So this now is.
So that is for Windows users.
For Mac and Linux users, please search for the terminal app and open the terminal app.
So both the Gate bash and the terminal app can be used to work on your computer or on a server.
It doesn't matter if it's a local computer or server, so you can use the git bash or the terminal to
do things like create new files, delete files, go to a certain directory, edit, text files, etc.
So once you open the gate, bash or the terminal, then the terminal or the git bash will point to a
certain directory to find that out what directory you are currently press TWD and that will tell you
where you are.
So I'm currently at C users.
AS So that's the first command you just learned p w d that prints out the current directory where you
are in your computer because at any time the command line interface points to a certain directory.
So anything we do now, for example, let's create a file, one text file, anything we do now is going
to be applied to that current directory, in this case, that directory.
So if I do touch file one, the TXT and press enter that will create a new file.
One txt.
So touch is the second command you just learned that is used to create new files.
Now you'd say, well, how do we see these files?
Well, to see the files you have in the current directory.
The current directory is that one again, you should press ls.
So there you go.
I have many files here and one of them is file one txt.
So that's the file that I've just created and it's an empty file for now.
Let's create a second file touch file to the txt and let's create a third file touch file.
Free that pie.
Let's call this pie.
Now, if you want to know only the text files, if you want to get a list of only the text files you
have in the current folder, you can do ls asterisk dot text press enter and that will list all the
text files you have in this directory.
Actually, only the files that end with a dot text extension to be clear about that.
So that command is saying, Oh, give me a list of all the files that have anything in front and then
they end with that text.
So touch was how to create a new file and to create a new directory you do m k dir followed by the name
of the directory, let's say data.
All right, so I've just created a directory.
However, know that you're still in the current directory as we have been since the start of the Common
Line interface.
Now, if you want to do something inside the data directory, first, you need to go inside the data
directory.
You need to change the current directory to that directory.
To do that, you use a seed which stands for change Directory seed data.
Be careful with the typos.
If you miss something, things will not work.
So I created the data folder here, and I'm going to that folder now.
With that, you'll see that in here the path changed to data.
And you can also double check that with p wd the command and it will tell you that you are currently
inside data.
This is an empty folder, so if you do less, you're going to get nothing in return.
So no files here currently, but any file you create now, such as file ten txt, any file you create
will be created inside this data directory.
So with ls you should get file 10.60.
That's the only file we have now inside data to go back one directory level you can use CD space followed
by two dots, two periods that will take you back to the previous directory.
So just check it with p.w dx.
So if you do LS now you're going to get the files of the C users as directory.
So we so how to see where we are currently with p.w dx we so how to list the contents of a directory
with LS we so How to create new files with touch and create new directory with m k dear Now How to remove
a file To remove a file you use our m followed by the name of the file.
For example, file one dot.
Now here is the trick I want to show to you.
If you want to alter complete a file name.
For example, you do file one and you don't want to type all the name through.
You may press the tab key on your keyboard and that will autocomplete the file name.
So file one the txt and then press enter and that will remove it will delete file one txt.
So if I do ls now file one.
The text is not here anymore.
If you want to remove a directory which has content inside for example the data directory, we can use
our m r followed by the name of the directory data press enter.
And now data is not part of.
This folder anymore.
So you can try to do seed data, but you will get an error.
It says no such file or directory because we deleted it in here.
How to rename a file?
Well, let's create a new file first touch file 20 dot txt to rename this file 2036 t to file 30 the
txt you use the v command followed by the name of the file you want to rename file 20 the txt and after
that goes the new name you want to give to this file file 30 dot txt press enter and less and you'll
see that file 30 The txt exists here, but file 20 has been removed.
So basically what M.V. is is actually a move command.
It moves a file from one file path to a new file path.
So that means you can also move file 30 the txt to a new directory for example data.
So let's create the data directory again with mkdir data and then move file 30.
So if you press tab while you have just typed some part of the name, for example, I typed in file
three and then I press tab and it showed me this.
So it didn't autocomplete the name to 530 to 60 because there are other files which have this name.
For example, file three.
So the command line interface doesn't know if you want to autocomplete this file or that file, but
if you specify a zero then tab, then it knows that you want to autocomplete that one.
So.
Oh, I pressed the enter command, but I had to also give the destination of the file.
So this is not the correct command.
You need to put the destination file.
So data file 30 dot txt and that will move that file to that directory.
You can also check the contents of a directory without being in that directory.
So currently we are in this directory s and we can check ls data.
By specifying the name of the folder, we can check for the files contained in that directory To copy
a file, you use a CPP command.
Let's copy.
For example, file three, file three.
That's P.
Let's copy it to data.
File three dot P.
Let's check data with LS data.
And there we go.
53. py is there.
Lastly, let's talk about how to view and how to edit the contents of text files with text files.
I mean any non-binary files such as dot, txt, dot, py, html, dot, Jason all the files which have
texts inside.
So to open a file for editing, you can use the nano command.
So let's create a file first.
Let's say touch file 50 dot p one.
So we have just created a file.
Now to open that file we use nano file 50 dot p y that will open the nano text editor.
So Nano is a text editor which works inside a command line interface.
So here you can simply type in text like that, You can press, enter, go to the next line press escape.
You cannot even click on somewhere else with your cursor, but you can use your arrow keys to move up
and down.
So like that.
So we can write something.
He'll, for example, print Hello and to save and exit this you can use control X.
You see these commands here.
So that symbol means you need to press the control key on your keyboard, followed by that letter.
In our case, we want to exit with control X, so control X that will ask us if we want to save the
buffer.
If you want to save, it's press y.
If not press nn otherwise press control.
C to cancel and go back to the editor.
So I'll press y then.
This asks you if you want to keep the file name as it is here or you want to change it.
If you want to keep it, you need to press enter.
So what we just did is we added some text to this dot p file and that's something you could also do
in a remote server.
So the remote server gives you access to its command line interface and you can edit your files using
the nano text editor.
If you simply want to see the contents of a file just to view it, you can use cat followed by the name
of the file file 50.
That's p y.
In this case, press enter and that will print out the contents of that file.
In our case it is print.
Hello.
And Cat was the last command you needed to learn for today as part of the most important commands.
So all these, by the way, all these were Unix commands.
Now these UNIX commands work on Linux operating systems, Mac operating systems, and also Windows operating
system.
When you use some tools such as the Git bash, Windows has its own command line as well, which you
can find it in here with CMD or PowerShell and these will be slightly different commands.
However, they are not as useful for a programmer as there are the Linux commands because most of the
servers you'll deploy your apps to will be based on Linux.
Windows commands are more useful for system administrators who manage Windows servers.
So for programmers, Linux will be the industry standard.
So I hope you find this useful and I'll see you later.
Thanks.