In most cases,
the software we need will be found in the official repositories provided by
Ubuntu.
We can see the default repositories configured for
this system by looking at this file.
Now, usually that's true.
But I'm using Ubuntu
24.04 which is the latest version of
Ubuntu as of this recording. But in previous versions of
Ubuntu, this is where this file is located.
But as you can see, we have a comment here that points to a new file name.
So let's take a look at that one.
Now, let's break this down line by line.
The first line types specifies the type of repository being defined.
Now in this case,
Deb indicates that this is a Debian style
repository which is the package format used by
Ubuntu.
This line tells the package manager for instance
app to expect Debian packages in this repository.
These dot Deb files are the packages themselves.
They are archives containing files such as the program files,
configuration files, documentation,
scripts to be run and so on the next line
specifies the uniform resource identifier or URI of this repository.
And in this case, it's an HTTPS URL pointing to the
Ubuntu archive mirror located in the United States
because as you can see it's us.archive.ubuntu.com.
Now the slash Ubuntu path at the end of
this URL indicates that this repository contains Ubuntu packages.
This line tells the package manager where to download packages from. Now.
Here we have suites.
This line specifies the suites or release components of this repository
in Ubuntu.
A suite is a set of packages that are associated
with a specific release or version of the distribution.
Our current version is Noble. Now, here we have three suites defined.
We have Noble and this is the main suite
for the Ubuntu released code named Noble Numbat.
This suite contains the core packages for the release
and we have Noble updates.
This suite contains updates to the packages in the Noble suite.
These packages are usually bug fixes,
security patches or minor feature enhancements.
And we also have Noble Backport.
This suite contains backported packages from newer Ubuntu releases.
So right now,
there aren't any newer ones but in the future there will be and these backport
are packages that have been rebuilt from newer releases to work on older releases.
So this allows you to access newer software without upgrading your entire system.
And next we have components.
This line specifies the components of the repository
in
Ubuntu.
Components are categories of packages that are grouped together
based on their licensing functionality or other criteria.
And here we have four components to find,
we have main.
This component contains packages that are free and
open source software and are officially supported by
Ubuntu
restricted.
This component contains packages that are free and open source software
but they may have some restrictions on their use or redistribution.
And we have universe.
This component contains packages that are free and
open source software but not officially supported by
Ubuntu Multiverse.
This component contains packages that are not free and open
source software and they may have other licensing restrictions.
Now, usually on a server, we only need Maine and Universe,
preferably only Maine if we can get away with it.
If we need something extra, not found in Maine, we can enable Universe as well
if it's not already enabled.
But as we can see by default, we have all four of these.
Now let's quit the editor and look at a different scenario regarding repositories.
In some cases, the software we need won't be included in the official
Ubuntu repositories at all. In other cases, the software will be included in
ubuntu's Universe section,
but it might be a very old version
and we might want the newest version
for both of these scenarios, we can enable third party repositories.
That means software repositories that aren't maintained by
Ubuntu but by a different team or company.
However, they're still compatible with this operating system.
Here's an example, let's say we want the latest stable version of Docker.
Now, the first thing we need to do is download a public key.
When the Docker team uploads a new package,
they sign it with their private key and with the public key,
our package manager can verify the signature.
This makes sure that the package hasn't been modified by any malicious users.
So to download this,
we'll use the cURL command and we'll pass the dash O option
to save the file in a file name called Docker dot key.
So we'll type in cURL and then the URL to the key and then dash O Docker dot key.
Great.
Next,
we use the GP G command to transform this key from text
format to a binary format that our package manager can understand.
This action is called de
armoring in GP G terminology.
This D armored key will be found in the Docker dot key dot GP G file.
So GP G simply saved the D armored content in
a file using the same name as our original file,
but added the dot GP G extension to the end of it.
Now, we'll have to move this into a directory belonging to our apt package manager,
namely the Etsy
app
keyrings directory where it keeps thirdparty
public keys to verify package signatures.
Finally, we should add the Docker repository to App's configuration,
but let's look at App's configuration directory first,
instead of adding the new repository to the
Ubuntu dot sources file that we looked at earlier,
we can create a new config file in the sources dot list dot D directory.
That way we keep things separate and organized.
Ubuntu dot Sources will contain the default entries and sources dot List dot D
directory will contain one file for each new repository we add to the system.
This keeps things really organized and neat.
And when we don't need the third party repository anymore,
we can just delete that config file from the directory.
Now,
older methods kept everything in one file which can make
it enormous and huge and hard to go through.
So this is a more organized way of doing things.
Let's create a new file in that folder called Docker dot list.
And we'll add in this configuration line.
Now we can see that this follows a different format from what we saw in the
Ubuntu sources file.
This follows the older convention of the sources dot list file,
the Deb keyword followed by the repository address,
the code name for the distribution
and the components that we want to cherry pick from for that repository.
And in this case,
we use the stable component to access the stable versions of Docker software.
But one more thing is required here,
namely the path to the public key used
to verify signatures for packages downloaded from Docker.
So we'll add this part in the following spot right after the Deb keyword.
Now the instructions for all of these steps are usually mentioned
on the website that provides access to the third party repository.
So we'll save the file and write it.
Now, after we save the file,
the last thing we want to do is update our package manager database again.
This way,
app downloads new information from the Docker repository and gets
up to date with the latest packages available there.
Now to confirm everything,
we can look for a line that mentions the address for the repository we just added
and we can see the Docker repository here in this output.
So everything works smoothly.
If you get an error mentioning that signatures can't be verified,
then the D armored public key hasn't been configured correctly.
Now, another type of repository,
Ubuntu lets you add are called PPAS short for personal package archive.
These simplify the whole process of adding a third party repository and
they also allow you to create your own third party repository.
For example, you can create a PP A and pick John as your username,
then name your repository, my latest app.
After you upload your packages there, other people can add this PP A with the ad
app repository command.
The next argument in this command starts with PP A colon
to tell this utility that this is a personal package archive.
Then followed by the user named John and the repository, my latest app.
But let's modify this to add a real PP A
and that's all
the command takes care of all the other details like modifying
Ubuntu dot sources files,
adding the public key used for verifying package signatures,
updating the package manager's database and so on
to list any PPAS we might have enabled,
we can use this command and pass the dash dash list option,
add apt repository, dash dash list.
And to remove a PP, we simply pass the
remove option followed by the same PP specification that we used before.
So in here, we'd use the same command but we type in dash dash
remove
and then press enter to confirm
that covers configuring the repositories of the package manager.
Now let's move on to our next lesson.