Let's start to use the terminal.
And in this video we are also going to focus on navigation and the file system.
So first of all how to open a terminal.
Well you have the terminal icon on the top here.
You can just click and it's going to open a terminal okay.
And then you can close it and open it again.
You can also click on the menu and go to accessories.
And here you will find as well the same terminal.
And note that you can open several terminal windows okay.
You can have as many as you want.
Now you can leave it like this.
There is just one thing I'm going to do so that you can actually read my screen.
It's going to be better for the course.
I'm going to right click here and go to preferences.
And I'm going to increase the size.
So the font size I'm going to go from 10 to 18.
Now you can just choose any value you want.
Just make sure it's readable but not too big so that you can fit a lot of stuff on the screen.
Okay.
So I'm going to select that okay.
And let's just open a new one.
All right.
So with this, you should be able to read easily.
Now we are on the terminal.
And to explain to you what we're going to do in the terminal, I'm going to open a file manager on the
side.
So first let's have a look at this file manager here.
If I open the file manager we are in a folder named slash home slash Pi.
And you can see we have the documents folder in this documents folder we have created our Python programs.
So if I go back here you can see that pi is kind of your user directory.
So if you have several users on the Raspberry Pi, several users on a computer, basically you have
different user directories.
And how it works in basically most Unix systems is you have you can see you have a root here slash.
So that's what we call the root of the file system.
And under this slash you have a lot of different folders.
So all of those folders are used for what the basic command lines, network system configuration, etc.
but we're not going to go too much into this.
But in this root folder you also have a home directory.
Okay.
And in that home directory you have basically a directory for each user.
So we only have one user.
It's called pi.
If I go there I am in my home directory.
That's your user main directory where you're going to put most of your files.
Now why do I talk about this.
So let's go back to the terminal and let's see one first comment to just know where you are.
This command is p w d okay so p w d you can just write this and then you press enter.
And this is going to give you the current path of where you are currently in the terminal.
And you can see we just open the terminal I do PWD and I see slash home slash Pi.
And this is exactly what we have here.
So this is our home directory with the user of pi.
And basically we are at the same place in the terminal.
Now the second command we're going to see is L s with LZ.
You can list everything that's well right here in this folder where you are right now.
So I just type LZ and I press enter.
And you can see I have.
So if you have stuff like this in bold and kind of blue purple bold, it means it's a directory, okay.
If it's in white it's going to be a file.
And so here we have the list of all directories inside this pi folder.
And you can see this is exactly what we have on the file manager.
So that's what I told you that basically the file manager and the terminal is the same thing.
We are navigating inside the same thing the same folders.
And so for example let's say I create a new file here in my file manager I do right click new file.
I will name it ABC.
I press enter okay.
So I have a new file name ABC.
I just one note is in Linux.
While any Unix system you don't need to add an extension to a file, you can have a file with any extension
or no extension at all.
Everything is valid.
So great!
I have my new file here.
Now if I do l s in the terminal, you can see that while we have the new file a, b, c.
All right.
So if there is something new here what is the same.
There is something in your home directory.
You're going to see it with ls.
And now if I remove this so I can do move to wastebasket.
If I remove that file and I do ls again.
And note that to do ls again I don't need to type the command.
Even if it's just two characters, I can use the up arrow.
Okay.
If I use the up arrow, I'm going to come back to the previous command.
So I run LS again and you can see now the ABC is gone.
Great.
So now you can already know where you are in the terminal and see what's inside where you are.
But there is something missing is how to go to a place.
Okay.
How to navigate to some place.
And for this you have another command.
Okay.
So here in this lesson we will see three commands PWD, LRS and CD.
With CD you can navigate to a directory.
And for example let's say I want to navigate to documents.
I just do CD and then space.
And then I put the name documents.
So make sure it's exactly the same.
I press enter and now you can see.
Well first of all here we see something.
You see already that we are in documents actually you see this.
You see tilde slash document.
So if I do PWD, we are in fact in slash home slash pi slash documents.
So when you see tilde it basically means home directory.
It also means slash home slash whatever user you have.
Okay.
So if you do tilde slash documents it means you are in the documents folder inside the home directory.
So that's the complete path here.
And if I do ls well, I have a test folder that I have created myself.
But then we have our Python programs.
Okay.
So just like if I would go here, I would open this file manager and go to documents.
And I have my Python programs.
So I can go in there and see all the Python code so I can do the same.
I do CD Python programs and I am in, so I can do PWD to verify that.
All right.
And I can do LS and I see all my files.
Okay.
Just like you see all the files here.
So you can see you can navigate in the terminal with just some comments.
So the CD command you can navigate the same way you would navigate by clicking on stuff here on the
file manager.
Now what if you want to go back for example I want to go back to the parent folder.
How to do this.
You can do CD and then so space and then dot dot.
If you do two dots it means the previous directory.
So if I press enter, you see, I am back in my documents.
Now, if I want to go back again, I can do it again.
CD dot dot.
And actually I just run the command before so I can use the up arrow and press enter.
And I am back to my home directory.
And you can combine also different folders at the same time with the CD command okay.
You don't need to do a CD command for every new folder.
For example, if I want to go back to this folder, I can write document and Python programs directly.
And there is one more thing is it's called auto completion.
So for example I write doc.
So I start with doc and I press tab and you can see I have documents.
And then I put Python.
So I start the name and then I press tab.
And I have the name that's automatically completed.
So I can press enter.
And you see we are back to this Python program folder.
So here with just one command you see we do something that we need two clicks here.
So we need to do double click here and a double click here on the file manager.
And we just use one command here.
And I can do the same to go back.
If I want to go back to my home directory I can do CD and then dot dot dot dot I press enter.
And I am back here now just to make sure you understand the autocompletion.
So here if I do ls I'm in my home directory.
Let's say I want to go to my documents folder so I can do CD and then d o c for example, and I press
tab and you see documents is auto completed.
Great.
Now what you can notice is that there are two folders that start with D and O.
So let's say I just put D and o.
Now I press tab once nothing happens.
If I press tab a second time, you see that now I have documents and downloads.
Those are suggestions.
So the auto completion will work.
If there is only one possibility to finish what you're typing here we have two possibilities, so the
terminal cannot choose for you.
You need to give enough.
Enough data, enough information.
So here, for example, if I want to go to downloads I will put d o w and I can press tab.
If I want to go to document I need to at least put a C.
Now for example, if I press tab here, I press tab twice.
You see that I have two different folders.
This one starts with P and this one starts with t.
So if I just put p I should be able to press tab again.
And then I press enter.
And we are in the directory.
And this can go very fast.
You see for example I do CD dot dot dot dot.
And then I do CD doc tab tab.
And you can see that it goes very fast.
So this of course with practice.
But the more you practice the faster you will become.
And then you can really navigate super fast in different places of your file system.
Now what if you type CD just like that CD and nothing else?
What you can see is that if you type CD, you will come back to your home Directory.
So if I click on the home button here, for example go to home folder.
We go to slash home slash pi okay.
So from anywhere if I'm in downloads and I do CD, I come back here from anywhere in the file system,
I do CD and I come back to the home directory.
All right.
So you have seen how to go to a directory with the what we call the relative path.
So depending on where you are for example here the relative path is to go here and say we are in this
home directory.
We go there, then we are here, we go there.
This is relative to where you are.
You also have seen just the CD command to go back to the home directory.
And you can use CD with an absolute path.
So the absolute means that you will start from a slash if you start CD, and then with a slash, it
means you are starting from the root of the file system.
So for example, how to go to the home directory and then to the documents folder, I will need to do
slash home Slash pi slash documents.
Okay.
And I can do the same thing with auto completion.
I can do home like this.
And then I just put P on nothing because there is just one user and then doc documents.
Okay.
So sometimes using the absolute path is going to be important, especially if you need to write a path
inside a Python file inside a Python script.
And you don't necessarily know where your Python script is going to be executed, then at least with
an absolute path, you know exactly where you go, okay.
Because if you run CD documents and Python program like this, it means you are already in the home
directory.
Okay.
If I run this command from anywhere else, it's not going to work.
But if I run this from anywhere, it's going to work because it's going to use the absolute path, okay?
Which always starts at the beginning of the file system.
So here it works.
All right.
And to finish with the CD, well there are different ways you can go to the same place.
For example, let's say I want to go.
So here in my home directory I want to go to my downloads folder.
And let's say I am here in my documents folder or even in my Python programs folder.
What I can do is I can use the relative path so I can do CD, dot, dot slash, dot dot, and actually
I can do another slash.
So here with this I will go back to the home directory and then downloads.
And I can use the auto completion okay.
So I go back one folder two folders and then downloads.
And I am there.
So that's one way to do it.
Another way to do it is actually so I often do that if the folder is close to the home directory, I
just do CD.
First I go to the home directory.
So from anywhere to the home directory and then CD downloads.
So it takes two commands instead of one.
But sometimes it's much faster because you are sure that with this you come back to the home directory
and then you can easily find the folder.
And finally, if we use the absolute path, I can do CD slash home slash pie.
I'm in my home directory and then slash downloads, and we're going to get to the same place.
So you can see we've three different ways here.
We can go to the same place.
Great.
And let's go back to the home directory.
So to go back to the home directory we do CD.
One last thing I'm going to come back to the LS command.
Okay.
If you do LS and then dash a you will see that we see actually more files.
And you see files with a dot.
So files with a dot and also folders with a dot.
And what are those files.
Well those files are hidden files.
So there is nothing really special about them.
Hidden just means that well you don't see them when you just type ls or from the file manager.
That's just about it.
And how to make a file or folder hidden.
You just add a dot in front of it.
Now if you do the dash A with ls, you can see all the hidden files and folders.
And we're going to come back to this in this course.
Actually it's the same in the file manager.
If you go to view, you can click on Show Hidden Files.
And you see we have well we have the same files.
It's just that by default it's going to be unchecked.
And you can do the same thing on windows.
And basically I think almost any operating system.
All right.
So in this lesson you have discovered the terminal and you saw how to navigate in the terminal.
So we have seen three commands PWD, CD and LS.
And with those three commands you can know where you are.
And you can navigate to anywhere in the terminal the same way you would do with a file manager.
And you have also understood a bit more how the file system works here on Unix system.
And what's great about what you learned here is that this knowledge is the same for different OSes based
on Unix.
If, for example, one day you need to work on ubuntu, you may have heard about this.
Well, if you need to work on that, you also going to use the same commands.
So what you learned here is going to be useful for anything you do with any Unix system.