WEBVTT

00:00.050 --> 00:06.170
Let's now see how to install and update software directly on the terminal for your Raspberry Pi.

00:06.200 --> 00:11.030
First of all, I'm going to use the command clear here to have a clean terminal.

00:11.030 --> 00:16.070
And while installing and updating software is something you will do quite often, whenever you need

00:16.070 --> 00:18.650
a new software, you will need to install a new package.

00:18.650 --> 00:23.930
And then, as you will see, it's quite important to keep all your packages up to date because you always

00:23.930 --> 00:27.350
have new versions of the packages that you already have installed.

00:27.350 --> 00:32.960
And as best practice, it's better to update the packages so you have the newer version available to

00:32.990 --> 00:35.900
use on your Raspberry Pi, on your computer or whatever.

00:35.900 --> 00:37.130
And there are two ways to do that.

00:37.130 --> 00:39.410
So we're going to see how to do that from the terminal of course.

00:39.410 --> 00:47.870
But you can also so if you go on the menu and then preferences add remove software, you see that you

00:47.870 --> 00:49.310
have a graphical menu here.

00:49.310 --> 00:55.280
And for example let's type software we want to install here I'm going to install vim.

00:55.280 --> 00:59.690
So vim is a text editor is a terminal text editor.

00:59.720 --> 01:03.850
I'm just going to use that for the purpose of installing a software.

01:03.880 --> 01:04.180
Okay.

01:04.210 --> 01:07.210
So you can press that if I press enter.

01:07.330 --> 01:10.300
So it's going to search the package.

01:10.300 --> 01:14.290
And where you have all the packages that correspond to vim.

01:14.290 --> 01:19.720
Then if you want you can just click on that and then click on okay to install the package.

01:19.750 --> 01:20.080
All right.

01:20.080 --> 01:22.360
So you can do that with the graphical interface.

01:22.360 --> 01:23.980
But we're going to do it from the terminal.

01:23.980 --> 01:28.360
And actually well you might think the graphical interface is better at first sight.

01:28.360 --> 01:33.310
But I tell you that when you are used to use the terminal for installing and updating software, you

01:33.310 --> 01:35.110
will only want to use the terminal.

01:35.110 --> 01:39.370
It's going to be much easier and quicker because the graphical interface can be annoying.

01:39.370 --> 01:41.710
It can be slow, not very practical.

01:41.710 --> 01:47.440
And also, what if you want to install several packages or specific versions and all that stuff?

01:47.440 --> 01:49.900
You have much more control with the terminal.

01:49.900 --> 01:52.120
So now let's see how to install this software.

01:52.120 --> 01:53.890
So it's called vim vim.

01:53.890 --> 01:58.420
And the first thing we need to do is to update the sources.

01:58.420 --> 02:04.560
So how does it works on a Unix system you have somewhere on your operating system a list of sources

02:04.560 --> 02:05.640
for packages.

02:05.640 --> 02:11.160
So those sources basically tell you where you can find actually not where you, but where the computer

02:11.160 --> 02:12.720
can find the packages.

02:12.720 --> 02:14.880
So the packages that are already installed.

02:14.880 --> 02:21.000
So when I say packages, I mean the software that is already installed or also the sources for the new

02:21.000 --> 02:24.960
packages to install and which version is the latest available.

02:24.960 --> 02:31.800
So then when you install a software, it's actually going to get the source from this list of sources

02:31.800 --> 02:36.330
that you have on the computer, which means that it's quite important to have sources that are up to

02:36.360 --> 02:36.900
date.

02:36.900 --> 02:41.760
So whenever we install something and we upgrade the package, we're going to want to make sure we have

02:41.760 --> 02:43.920
the latest available sources.

02:43.920 --> 02:45.690
And to do that you have the comment.

02:45.690 --> 02:51.720
So we're going to use the command apt in this lesson and then update and note here that I'm going to

02:51.720 --> 02:52.860
get an error.

02:52.860 --> 02:54.900
And the error is basically here.

02:54.900 --> 02:56.970
You see permission denied.

02:57.000 --> 02:59.010
So I'm going to put it a bit bigger here.

02:59.010 --> 03:01.020
And why do we have permission denied.

03:01.020 --> 03:04.770
Because well here you see we are running any command.

03:04.770 --> 03:07.970
So we are in the terminal as the Pi user.

03:07.970 --> 03:09.020
But there is another.

03:09.050 --> 03:11.840
Let's say another user is the admin user.

03:11.870 --> 03:14.870
Okay, so we are not logged in as admin.

03:14.870 --> 03:18.170
We are just logged in as a user, a Pi user.

03:18.170 --> 03:24.290
And to do this command, to execute this command you need admin privileges and how to get admin privileges

03:24.290 --> 03:25.070
for a command.

03:25.100 --> 03:26.120
Well it's quite simple.

03:26.120 --> 03:29.060
You will need to write sudo before the command.

03:29.060 --> 03:31.370
So sudo apt update.

03:31.400 --> 03:33.200
Okay so sudo is now really a command.

03:33.230 --> 03:36.440
It's basically a keyword you put in front of a command.

03:36.440 --> 03:43.310
So that could be any command so that you execute this command as an administrator if you are used to

03:43.340 --> 03:43.970
windows.

03:44.000 --> 03:49.340
Well it's just the same thing as if you click on something and you do so you do right click and something

03:49.340 --> 03:51.680
like execute as an administrator.

03:51.680 --> 03:53.360
So let's run that command.

03:53.360 --> 03:58.280
And well it might sometimes when you do sudo it might ask you for the password.

03:58.280 --> 03:59.630
So you just type the password.

03:59.660 --> 04:00.560
It's not going to show it.

04:00.560 --> 04:03.170
But you just type the password and you press enter.

04:03.170 --> 04:04.520
And then you will see this.

04:04.520 --> 04:08.500
So you might have something that's a bit different.

04:08.500 --> 04:11.110
You might not have exactly the same sources as me.

04:11.140 --> 04:11.350
Okay.

04:11.350 --> 04:12.160
It depends.

04:12.190 --> 04:16.240
But you will see something like this with get and then a URL for sources.

04:16.240 --> 04:17.200
You don't need to worry.

04:17.230 --> 04:19.540
Worry about that when you see this.

04:19.540 --> 04:26.380
You just know that you fetched all the new sources for the packages you already have and for the packages

04:26.380 --> 04:27.190
you can install.

04:27.190 --> 04:32.260
Now, once you have done the sudo apt update, you can install a package with.

04:32.290 --> 04:39.040
So here again we need to do sudo and then apt space and then install and then space.

04:39.040 --> 04:40.780
And then the name of the package.

04:40.780 --> 04:45.220
The name of the package we're going to install here for this example is vim.

04:45.220 --> 04:49.840
So I do this and then I press enter okay.

04:49.870 --> 04:52.270
And you're going to have some logs okay.

04:52.300 --> 04:56.110
It will tell you what will be installed what needs to be installed.

04:56.110 --> 05:00.250
So actually here we install one package but it needs to install two packages.

05:00.250 --> 05:02.050
Because there is a dependency here.

05:02.050 --> 05:07.090
It's going to tell you how much it needs to download and how much space is going to be added.

05:07.120 --> 05:07.330
Okay.

05:07.330 --> 05:11.400
So all those informations you have them here and then do you want to continue.

05:11.400 --> 05:13.530
So you can type Y for.

05:13.530 --> 05:15.180
Yes or just press enter.

05:15.180 --> 05:21.210
And then when you press enter here and this is going to download the package and then to install it.

05:21.210 --> 05:23.100
So this one is quite small.

05:23.370 --> 05:25.350
So you can see it's already downloaded.

05:25.350 --> 05:29.700
And then you have a progress bar that's gonna install the package.

05:29.700 --> 05:31.620
So let's wait a few seconds.

05:32.340 --> 05:32.640
All right.

05:32.640 --> 05:35.160
So that was maybe ten 20s for me.

05:35.160 --> 05:39.420
So it's not really that long because this package also is quite small.

05:39.420 --> 05:44.250
And well, now that I have done this command, the package vim is installed and now I can run it.

05:44.250 --> 05:47.280
So for example I have the vim command.

05:47.370 --> 05:55.170
I can press enter and you can see we will get to a uh so that's a text editor in the terminal.

05:55.170 --> 05:56.070
So that's another one.

05:56.070 --> 05:58.590
You have seen Nano but there is also vim.

05:58.590 --> 06:00.930
So I'm not going to talk more about vim.

06:00.930 --> 06:03.540
It's just an example of a package to install.

06:03.540 --> 06:07.830
But just a quick note is that this is a quite useful text editor.

06:07.830 --> 06:10.350
It's much more complex to start with.

06:10.350 --> 06:15.420
So it has a learning curve, but it's also quite powerful and you can do a lot of stuff with it.

06:15.420 --> 06:17.850
So it's a quite popular text editor.

06:17.850 --> 06:22.680
And if you want after this course, you can try to learn how to use it as an additional step.

06:22.680 --> 06:24.060
But for now, well that's it.

06:24.120 --> 06:28.770
The only thing is, if you have run the command vim like me, you may think, okay, how do we get out

06:28.770 --> 06:29.460
of this?

06:29.460 --> 06:33.390
And you can see here you type colon Q and enter to exit.

06:33.390 --> 06:35.310
So I just type colon here.

06:35.310 --> 06:40.620
You see I have this and then I type Q enter and I'm back to the terminal.

06:40.650 --> 06:41.010
Great.

06:41.010 --> 06:43.950
So we have run the software that we just installed.

06:43.980 --> 06:46.500
Now let's say you want to remove that software.

06:46.500 --> 06:48.180
How to remove that software.

06:48.210 --> 06:49.680
Well you're going to do the same thing.

06:49.680 --> 06:52.830
So sudo for admin privileges and then apt.

06:53.400 --> 06:59.880
And then instead of install you have remove remove like that and then the name.

06:59.970 --> 07:01.530
So that's going to be vim.

07:02.700 --> 07:03.120
Okay.

07:03.120 --> 07:06.210
It might ask you do you want to remove and just press enter here.

07:06.240 --> 07:10.440
Or you can also put Y and enter and it's going to remove it.

07:10.440 --> 07:11.630
So it should be quite quick.

07:11.660 --> 07:17.030
And now what you can see for example, if I try to run vim again you see we have an error like this.

07:17.030 --> 07:22.220
So you may have a no command found or no such file or directory.

07:22.250 --> 07:25.760
Okay, so you can see now that vim has been uninstalled.

07:25.790 --> 07:26.240
Great.

07:26.240 --> 07:30.080
So to install you can see that we first update the sources.

07:30.230 --> 07:35.870
Then you use the install here command with apt and sudo and with the software.

07:35.870 --> 07:37.040
And then you can use the software.

07:37.040 --> 07:39.800
And then you can also remove the software with remove.

07:39.800 --> 07:41.270
So it's not that complicated.

07:41.300 --> 07:43.100
Now let me clear that.

07:43.460 --> 07:48.470
And now let's talk about upgrading packages because well it's nice to install packages.

07:48.470 --> 07:53.540
But now you have installed this package with the specific version that was released, let's say a few

07:53.540 --> 07:58.700
days ago or a few weeks ago or whatever, but then it's not going to automatically upgrade itself.

07:58.730 --> 07:58.910
Okay.

07:58.940 --> 08:02.990
So you will need to manually upgrade the packages that you have on your computer.

08:02.990 --> 08:08.210
And upgrading is quite important because you want to have the latest versions for the packages.

08:08.210 --> 08:14.200
So you have the new functionalities, but also sometimes you have some safety and security updates that

08:14.200 --> 08:17.890
you want to make sure that you have on your computer or your Raspberry Pi.

08:17.920 --> 08:19.510
So how to upgrade packages?

08:19.510 --> 08:21.580
Well, first of all, we just did that.

08:21.580 --> 08:23.530
But I'm going to run this command again.

08:23.560 --> 08:25.930
You do a sudo apt update.

08:26.560 --> 08:29.200
So you update all the sources that you have.

08:29.230 --> 08:33.010
It's going to fetch all the sources for all the packages that you already have installed.

08:33.010 --> 08:38.800
So you know what actually your computer knows what is the latest version for each package.

08:38.800 --> 08:42.970
And you can see here, actually we have an information that I haven't mentioned it before, but now

08:42.970 --> 08:43.720
it's quite important.

08:43.720 --> 08:47.290
You see we have 72 packages that can be upgraded.

08:47.290 --> 08:49.390
So of course the number is going to be different for you.

08:49.390 --> 08:50.800
It may be less, it may be more.

08:50.800 --> 08:54.190
But this is well this is actually quite a lot.

08:54.220 --> 08:59.920
And to upgrade all of them I will do a sudo apt upgrade.

08:59.950 --> 09:06.070
I press enter and you can see well we have a lot more stuff.

09:06.100 --> 09:09.910
And so you see that well we actually need new packages.

09:09.910 --> 09:15.010
And then some packages are going to be upgraded is gonna download here.

09:15.010 --> 09:21.730
You see almost 400MB and it's going to add almost 70MB of space.

09:21.730 --> 09:22.870
So that's quite a lot.

09:22.900 --> 09:24.190
I'm going to press enter.

09:24.190 --> 09:26.320
And well now you need to wait.

09:26.320 --> 09:28.210
So it's going to take a few minutes.

09:28.210 --> 09:33.070
And well basically the more packages you have to upgrade the longer it will take.

09:33.820 --> 09:35.530
And it seemed to be done.

09:35.530 --> 09:38.890
So after was something like ten minutes for me.

09:38.890 --> 09:43.750
All the packages are updated and then well, so that took ten minutes.

09:43.750 --> 09:47.890
But if you do it more frequently, of course that's going to be much faster.

09:47.890 --> 09:50.440
And now all the packages are up to date.

09:50.440 --> 09:51.400
So just to make sure.

09:51.430 --> 09:58.420
So I'm going to press on the up arrow to do a sudo apt upgrade again and let's see what we have okay.

09:58.450 --> 09:59.140
And you can see.

09:59.140 --> 10:03.430
So I kept that for now is that you may have sometimes messages like that.

10:03.430 --> 10:08.470
So the following packages were automatically installed and are no longer required.

10:08.500 --> 10:10.090
You see a bunch of packages.

10:10.090 --> 10:13.600
We even have vim runtime that was installed with vim previously.

10:13.600 --> 10:17.120
And well those packages, as you can see, they were automatically installed.

10:17.120 --> 10:22.700
They are not necessarily removed when you remove packages or when you no longer need them.

10:22.700 --> 10:26.330
So you have to remove them with the sudo apt autoremove.

10:26.330 --> 10:35.030
So sudo apt auto remove I can press enter and then I press yes.

10:37.670 --> 10:38.030
All right.

10:38.030 --> 10:39.350
So that was quite quick.

10:39.350 --> 10:42.650
And now I can be sure that all my packages are up to date.

10:42.650 --> 10:46.160
And I don't have any packages that I don't need anymore.

10:46.160 --> 10:48.260
So that's it for updating packages.

10:48.260 --> 10:52.340
Once again, this is something very important on other operating systems.

10:52.340 --> 10:55.190
For example on windows, they don't really give you the choice, okay.

10:55.220 --> 10:57.200
They force you to upgrade the software.

10:57.200 --> 11:01.820
Sometimes you open your computer and you have to wait 20 minutes so they can access to your windows

11:01.820 --> 11:02.360
desktop.

11:02.360 --> 11:04.460
With Unix, they don't force you to do that.

11:04.460 --> 11:07.130
You have more freedom, but because you have more freedom.

11:07.130 --> 11:12.350
Also, don't forget to do it because if you don't, if you never update your packages, they will not

11:12.380 --> 11:14.000
update by themselves.

11:14.000 --> 11:16.760
So keep that in mind and try to do it quite often.
