WEBVTT

00:00.050 --> 00:01.640
Let's start to use the terminal.

00:01.640 --> 00:06.350
And in this video we are also going to focus on navigation and the file system.

00:06.350 --> 00:08.990
So first of all how to open a terminal.

00:08.990 --> 00:11.030
Well you have the terminal icon on the top here.

00:11.030 --> 00:14.360
You can just click and it's going to open a terminal okay.

00:14.390 --> 00:17.240
And then you can close it and open it again.

00:17.240 --> 00:21.260
You can also click on the menu and go to accessories.

00:21.260 --> 00:25.070
And here you will find as well the same terminal.

00:25.070 --> 00:28.220
And note that you can open several terminal windows okay.

00:28.250 --> 00:30.650
You can have as many as you want.

00:31.700 --> 00:33.770
Now you can leave it like this.

00:33.770 --> 00:37.850
There is just one thing I'm going to do so that you can actually read my screen.

00:37.850 --> 00:39.590
It's going to be better for the course.

00:39.590 --> 00:43.100
I'm going to right click here and go to preferences.

00:43.100 --> 00:45.560
And I'm going to increase the size.

00:45.560 --> 00:50.570
So the font size I'm going to go from 10 to 18.

00:50.720 --> 00:52.490
Now you can just choose any value you want.

00:52.520 --> 00:57.440
Just make sure it's readable but not too big so that you can fit a lot of stuff on the screen.

00:57.470 --> 00:57.710
Okay.

00:57.740 --> 01:00.500
So I'm going to select that okay.

01:00.500 --> 01:02.820
And let's just open a new one.

01:04.020 --> 01:04.320
All right.

01:04.320 --> 01:06.780
So with this, you should be able to read easily.

01:06.810 --> 01:08.400
Now we are on the terminal.

01:08.400 --> 01:15.240
And to explain to you what we're going to do in the terminal, I'm going to open a file manager on the

01:15.240 --> 01:16.260
side.

01:16.290 --> 01:19.860
So first let's have a look at this file manager here.

01:19.860 --> 01:26.040
If I open the file manager we are in a folder named slash home slash Pi.

01:26.040 --> 01:31.530
And you can see we have the documents folder in this documents folder we have created our Python programs.

01:31.530 --> 01:36.510
So if I go back here you can see that pi is kind of your user directory.

01:36.510 --> 01:41.970
So if you have several users on the Raspberry Pi, several users on a computer, basically you have

01:41.970 --> 01:43.680
different user directories.

01:43.680 --> 01:51.720
And how it works in basically most Unix systems is you have you can see you have a root here slash.

01:51.720 --> 01:55.140
So that's what we call the root of the file system.

01:55.140 --> 01:59.700
And under this slash you have a lot of different folders.

01:59.700 --> 02:07.650
So all of those folders are used for what the basic command lines, network system configuration, etc.

02:07.650 --> 02:09.840
but we're not going to go too much into this.

02:09.840 --> 02:15.660
But in this root folder you also have a home directory.

02:15.690 --> 02:15.930
Okay.

02:15.960 --> 02:20.790
And in that home directory you have basically a directory for each user.

02:20.790 --> 02:21.990
So we only have one user.

02:21.990 --> 02:22.920
It's called pi.

02:22.950 --> 02:25.710
If I go there I am in my home directory.

02:25.710 --> 02:30.330
That's your user main directory where you're going to put most of your files.

02:30.360 --> 02:32.130
Now why do I talk about this.

02:32.130 --> 02:38.100
So let's go back to the terminal and let's see one first comment to just know where you are.

02:38.130 --> 02:45.300
This command is p w d okay so p w d you can just write this and then you press enter.

02:45.300 --> 02:51.270
And this is going to give you the current path of where you are currently in the terminal.

02:51.270 --> 02:57.600
And you can see we just open the terminal I do PWD and I see slash home slash Pi.

02:57.600 --> 03:00.120
And this is exactly what we have here.

03:00.120 --> 03:03.160
So this is our home directory with the user of pi.

03:03.160 --> 03:07.540
And basically we are at the same place in the terminal.

03:07.570 --> 03:12.460
Now the second command we're going to see is L s with LZ.

03:12.490 --> 03:18.400
You can list everything that's well right here in this folder where you are right now.

03:18.400 --> 03:21.130
So I just type LZ and I press enter.

03:21.190 --> 03:22.690
And you can see I have.

03:22.690 --> 03:30.070
So if you have stuff like this in bold and kind of blue purple bold, it means it's a directory, okay.

03:30.100 --> 03:32.320
If it's in white it's going to be a file.

03:32.350 --> 03:38.050
And so here we have the list of all directories inside this pi folder.

03:38.050 --> 03:41.950
And you can see this is exactly what we have on the file manager.

03:41.950 --> 03:45.880
So that's what I told you that basically the file manager and the terminal is the same thing.

03:45.880 --> 03:50.590
We are navigating inside the same thing the same folders.

03:50.590 --> 03:57.010
And so for example let's say I create a new file here in my file manager I do right click new file.

03:57.040 --> 03:58.720
I will name it ABC.

03:59.020 --> 04:00.940
I press enter okay.

04:00.970 --> 04:02.800
So I have a new file name ABC.

04:03.130 --> 04:05.510
I just one note is in Linux.

04:05.540 --> 04:11.870
While any Unix system you don't need to add an extension to a file, you can have a file with any extension

04:11.870 --> 04:13.550
or no extension at all.

04:13.550 --> 04:14.810
Everything is valid.

04:14.810 --> 04:15.560
So great!

04:15.560 --> 04:16.910
I have my new file here.

04:16.940 --> 04:24.680
Now if I do l s in the terminal, you can see that while we have the new file a, b, c.

04:24.950 --> 04:25.250
All right.

04:25.280 --> 04:27.950
So if there is something new here what is the same.

04:28.040 --> 04:29.750
There is something in your home directory.

04:29.750 --> 04:31.400
You're going to see it with ls.

04:31.400 --> 04:37.070
And now if I remove this so I can do move to wastebasket.

04:38.300 --> 04:41.870
If I remove that file and I do ls again.

04:41.870 --> 04:45.050
And note that to do ls again I don't need to type the command.

04:45.080 --> 04:48.680
Even if it's just two characters, I can use the up arrow.

04:48.710 --> 04:48.860
Okay.

04:48.890 --> 04:51.590
If I use the up arrow, I'm going to come back to the previous command.

04:51.590 --> 04:55.940
So I run LS again and you can see now the ABC is gone.

04:55.940 --> 04:56.360
Great.

04:56.360 --> 05:01.700
So now you can already know where you are in the terminal and see what's inside where you are.

05:01.700 --> 05:05.450
But there is something missing is how to go to a place.

05:05.480 --> 05:05.690
Okay.

05:05.720 --> 05:08.030
How to navigate to some place.

05:08.060 --> 05:10.190
And for this you have another command.

05:10.220 --> 05:10.370
Okay.

05:10.370 --> 05:15.710
So here in this lesson we will see three commands PWD, LRS and CD.

05:15.740 --> 05:19.520
With CD you can navigate to a directory.

05:19.520 --> 05:22.880
And for example let's say I want to navigate to documents.

05:22.880 --> 05:25.670
I just do CD and then space.

05:25.670 --> 05:27.830
And then I put the name documents.

05:27.890 --> 05:30.020
So make sure it's exactly the same.

05:30.260 --> 05:32.990
I press enter and now you can see.

05:33.020 --> 05:35.720
Well first of all here we see something.

05:35.720 --> 05:40.250
You see already that we are in documents actually you see this.

05:40.250 --> 05:43.220
You see tilde slash document.

05:43.250 --> 05:49.820
So if I do PWD, we are in fact in slash home slash pi slash documents.

05:49.820 --> 05:53.480
So when you see tilde it basically means home directory.

05:53.510 --> 05:57.920
It also means slash home slash whatever user you have.

05:57.950 --> 05:58.310
Okay.

05:58.310 --> 06:04.040
So if you do tilde slash documents it means you are in the documents folder inside the home directory.

06:04.040 --> 06:05.850
So that's the complete path here.

06:05.850 --> 06:09.990
And if I do ls well, I have a test folder that I have created myself.

06:09.990 --> 06:12.000
But then we have our Python programs.

06:12.030 --> 06:12.270
Okay.

06:12.300 --> 06:17.370
So just like if I would go here, I would open this file manager and go to documents.

06:17.550 --> 06:19.290
And I have my Python programs.

06:19.290 --> 06:23.070
So I can go in there and see all the Python code so I can do the same.

06:23.100 --> 06:34.080
I do CD Python programs and I am in, so I can do PWD to verify that.

06:34.470 --> 06:34.890
All right.

06:34.890 --> 06:39.210
And I can do LS and I see all my files.

06:39.240 --> 06:39.420
Okay.

06:39.450 --> 06:41.160
Just like you see all the files here.

06:41.160 --> 06:45.780
So you can see you can navigate in the terminal with just some comments.

06:45.780 --> 06:51.900
So the CD command you can navigate the same way you would navigate by clicking on stuff here on the

06:51.900 --> 06:52.740
file manager.

06:52.770 --> 06:56.490
Now what if you want to go back for example I want to go back to the parent folder.

06:56.490 --> 06:57.570
How to do this.

06:57.570 --> 07:01.920
You can do CD and then so space and then dot dot.

07:01.950 --> 07:04.740
If you do two dots it means the previous directory.

07:04.740 --> 07:08.860
So if I press enter, you see, I am back in my documents.

07:08.890 --> 07:12.220
Now, if I want to go back again, I can do it again.

07:12.250 --> 07:13.690
CD dot dot.

07:13.690 --> 07:18.850
And actually I just run the command before so I can use the up arrow and press enter.

07:18.850 --> 07:20.950
And I am back to my home directory.

07:20.950 --> 07:25.960
And you can combine also different folders at the same time with the CD command okay.

07:25.990 --> 07:28.900
You don't need to do a CD command for every new folder.

07:28.900 --> 07:35.110
For example, if I want to go back to this folder, I can write document and Python programs directly.

07:35.110 --> 07:38.500
And there is one more thing is it's called auto completion.

07:38.500 --> 07:40.780
So for example I write doc.

07:40.900 --> 07:46.000
So I start with doc and I press tab and you can see I have documents.

07:46.000 --> 07:47.950
And then I put Python.

07:47.950 --> 07:51.280
So I start the name and then I press tab.

07:51.280 --> 07:53.920
And I have the name that's automatically completed.

07:53.920 --> 07:55.390
So I can press enter.

07:55.390 --> 07:58.690
And you see we are back to this Python program folder.

07:58.690 --> 08:04.960
So here with just one command you see we do something that we need two clicks here.

08:04.960 --> 08:08.950
So we need to do double click here and a double click here on the file manager.

08:08.950 --> 08:10.930
And we just use one command here.

08:10.930 --> 08:12.700
And I can do the same to go back.

08:12.700 --> 08:18.640
If I want to go back to my home directory I can do CD and then dot dot dot dot I press enter.

08:18.640 --> 08:22.840
And I am back here now just to make sure you understand the autocompletion.

08:22.840 --> 08:25.960
So here if I do ls I'm in my home directory.

08:25.960 --> 08:34.660
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

08:34.690 --> 08:37.630
tab and you see documents is auto completed.

08:37.660 --> 08:38.110
Great.

08:38.140 --> 08:44.650
Now what you can notice is that there are two folders that start with D and O.

08:44.650 --> 08:47.050
So let's say I just put D and o.

08:47.080 --> 08:49.540
Now I press tab once nothing happens.

08:49.540 --> 08:54.460
If I press tab a second time, you see that now I have documents and downloads.

08:54.460 --> 08:56.320
Those are suggestions.

08:56.320 --> 08:58.540
So the auto completion will work.

08:58.780 --> 09:01.150
So the auto completion will work.

09:01.150 --> 09:07.700
If there is only one possibility to finish what you're typing here we have two possibilities, so the

09:07.700 --> 09:09.680
terminal cannot choose for you.

09:09.710 --> 09:11.000
You need to give enough.

09:11.150 --> 09:12.920
Enough data, enough information.

09:12.920 --> 09:18.380
So here, for example, if I want to go to downloads I will put d o w and I can press tab.

09:18.380 --> 09:21.800
If I want to go to document I need to at least put a C.

09:21.830 --> 09:25.160
Now for example, if I press tab here, I press tab twice.

09:25.160 --> 09:28.340
You see that I have two different folders.

09:28.340 --> 09:31.190
This one starts with P and this one starts with t.

09:31.190 --> 09:34.610
So if I just put p I should be able to press tab again.

09:34.610 --> 09:35.780
And then I press enter.

09:35.780 --> 09:37.970
And we are in the directory.

09:37.970 --> 09:39.530
And this can go very fast.

09:39.530 --> 09:42.470
You see for example I do CD dot dot dot dot.

09:42.470 --> 09:45.740
And then I do CD doc tab tab.

09:45.740 --> 09:48.290
And you can see that it goes very fast.

09:48.290 --> 09:49.730
So this of course with practice.

09:49.730 --> 09:52.310
But the more you practice the faster you will become.

09:52.310 --> 09:57.470
And then you can really navigate super fast in different places of your file system.

09:57.470 --> 10:02.180
Now what if you type CD just like that CD and nothing else?

10:02.630 --> 10:07.770
What you can see is that if you type CD, you will come back to your home Directory.

10:07.770 --> 10:11.520
So if I click on the home button here, for example go to home folder.

10:11.520 --> 10:15.000
We go to slash home slash pi okay.

10:15.030 --> 10:22.200
So from anywhere if I'm in downloads and I do CD, I come back here from anywhere in the file system,

10:22.200 --> 10:25.050
I do CD and I come back to the home directory.

10:25.080 --> 10:25.470
All right.

10:25.470 --> 10:30.540
So you have seen how to go to a directory with the what we call the relative path.

10:30.540 --> 10:35.700
So depending on where you are for example here the relative path is to go here and say we are in this

10:35.700 --> 10:36.330
home directory.

10:36.360 --> 10:38.970
We go there, then we are here, we go there.

10:39.000 --> 10:41.100
This is relative to where you are.

10:41.160 --> 10:44.550
You also have seen just the CD command to go back to the home directory.

10:44.550 --> 10:47.670
And you can use CD with an absolute path.

10:47.670 --> 10:55.530
So the absolute means that you will start from a slash if you start CD, and then with a slash, it

10:55.530 --> 10:58.800
means you are starting from the root of the file system.

10:58.800 --> 11:05.460
So for example, how to go to the home directory and then to the documents folder, I will need to do

11:05.490 --> 11:11.940
slash home Slash pi slash documents.

11:12.360 --> 11:12.840
Okay.

11:12.870 --> 11:15.330
And I can do the same thing with auto completion.

11:15.330 --> 11:17.520
I can do home like this.

11:17.520 --> 11:24.780
And then I just put P on nothing because there is just one user and then doc documents.

11:24.810 --> 11:25.080
Okay.

11:25.110 --> 11:31.800
So sometimes using the absolute path is going to be important, especially if you need to write a path

11:31.800 --> 11:34.710
inside a Python file inside a Python script.

11:34.710 --> 11:40.350
And you don't necessarily know where your Python script is going to be executed, then at least with

11:40.380 --> 11:43.680
an absolute path, you know exactly where you go, okay.

11:43.710 --> 11:49.380
Because if you run CD documents and Python program like this, it means you are already in the home

11:49.380 --> 11:50.100
directory.

11:50.130 --> 11:50.370
Okay.

11:50.400 --> 11:53.310
If I run this command from anywhere else, it's not going to work.

11:53.310 --> 11:58.500
But if I run this from anywhere, it's going to work because it's going to use the absolute path, okay?

11:58.530 --> 12:02.370
Which always starts at the beginning of the file system.

12:02.370 --> 12:03.840
So here it works.

12:03.870 --> 12:04.260
All right.

12:04.260 --> 12:08.640
And to finish with the CD, well there are different ways you can go to the same place.

12:08.640 --> 12:10.390
For example, let's say I want to go.

12:10.390 --> 12:13.840
So here in my home directory I want to go to my downloads folder.

12:13.840 --> 12:18.940
And let's say I am here in my documents folder or even in my Python programs folder.

12:18.940 --> 12:26.710
What I can do is I can use the relative path so I can do CD, dot, dot slash, dot dot, and actually

12:26.710 --> 12:27.640
I can do another slash.

12:27.640 --> 12:32.620
So here with this I will go back to the home directory and then downloads.

12:32.620 --> 12:34.840
And I can use the auto completion okay.

12:34.840 --> 12:37.810
So I go back one folder two folders and then downloads.

12:38.020 --> 12:39.100
And I am there.

12:39.100 --> 12:40.450
So that's one way to do it.

12:40.450 --> 12:46.660
Another way to do it is actually so I often do that if the folder is close to the home directory, I

12:46.660 --> 12:47.350
just do CD.

12:47.380 --> 12:49.210
First I go to the home directory.

12:49.210 --> 12:53.890
So from anywhere to the home directory and then CD downloads.

12:53.890 --> 12:56.050
So it takes two commands instead of one.

12:56.050 --> 13:01.180
But sometimes it's much faster because you are sure that with this you come back to the home directory

13:01.180 --> 13:03.280
and then you can easily find the folder.

13:03.280 --> 13:12.320
And finally, if we use the absolute path, I can do CD slash home slash pie.

13:12.350 --> 13:17.660
I'm in my home directory and then slash downloads, and we're going to get to the same place.

13:17.660 --> 13:20.600
So you can see we've three different ways here.

13:20.600 --> 13:22.700
We can go to the same place.

13:22.730 --> 13:23.300
Great.

13:23.300 --> 13:24.800
And let's go back to the home directory.

13:24.800 --> 13:26.750
So to go back to the home directory we do CD.

13:27.110 --> 13:31.550
One last thing I'm going to come back to the LS command.

13:31.580 --> 13:32.090
Okay.

13:32.090 --> 13:39.200
If you do LS and then dash a you will see that we see actually more files.

13:39.200 --> 13:41.210
And you see files with a dot.

13:41.210 --> 13:44.240
So files with a dot and also folders with a dot.

13:44.270 --> 13:45.710
And what are those files.

13:45.710 --> 13:48.680
Well those files are hidden files.

13:48.680 --> 13:50.810
So there is nothing really special about them.

13:50.810 --> 13:56.360
Hidden just means that well you don't see them when you just type ls or from the file manager.

13:56.360 --> 13:57.410
That's just about it.

13:57.410 --> 13:59.660
And how to make a file or folder hidden.

13:59.660 --> 14:01.760
You just add a dot in front of it.

14:01.760 --> 14:07.130
Now if you do the dash A with ls, you can see all the hidden files and folders.

14:07.130 --> 14:08.930
And we're going to come back to this in this course.

14:08.930 --> 14:11.480
Actually it's the same in the file manager.

14:11.480 --> 14:16.130
If you go to view, you can click on Show Hidden Files.

14:16.130 --> 14:18.590
And you see we have well we have the same files.

14:18.590 --> 14:21.830
It's just that by default it's going to be unchecked.

14:21.830 --> 14:23.600
And you can do the same thing on windows.

14:23.600 --> 14:26.990
And basically I think almost any operating system.

14:27.020 --> 14:27.530
All right.

14:27.530 --> 14:34.130
So in this lesson you have discovered the terminal and you saw how to navigate in the terminal.

14:34.130 --> 14:37.970
So we have seen three commands PWD, CD and LS.

14:37.970 --> 14:40.370
And with those three commands you can know where you are.

14:40.370 --> 14:45.860
And you can navigate to anywhere in the terminal the same way you would do with a file manager.

14:45.860 --> 14:51.530
And you have also understood a bit more how the file system works here on Unix system.

14:51.530 --> 14:57.170
And what's great about what you learned here is that this knowledge is the same for different OSes based

14:57.170 --> 14:58.220
on Unix.

14:58.250 --> 15:02.210
If, for example, one day you need to work on ubuntu, you may have heard about this.

15:02.210 --> 15:05.900
Well, if you need to work on that, you also going to use the same commands.

15:05.900 --> 15:11.570
So what you learned here is going to be useful for anything you do with any Unix system.
