- So let's talk about apt.
Apt is the Ubuntu equivalent to yum and dnf.
It's the Ubuntu software manager.
Apt is a newer replacement of older utilities
like apt-cache and apt-get.
In older versions of Ubuntu, you had apt hyphen whatever.
Now there's a main interface,
and this main interface is just apt
followed by the functionality that you want to perform.
Now like yum, apt was developed to work with packages
in an intuitive way.
So apt repositories are defined in /etc/apt/sources.list,
and there's also an option to work with drop-in files
that you would store in /etc/apt/sources.d.
Now how do we work with apt?
Well, first you need to make sure
that the local list of packages is updated
to the most recent version of packages
by using the apt update command.
And you can use apt search to search for packages.
The apt install command is what you are going to use next,
and that'll install the package.
Now you will notice if you install packages with apt,
if a package contains a service,
then it will be started and enabled automatically.
So you don't have to deal
with the systemctl command separately.
You can use apt upgrade to upgrade packages
or even apt dist-upgrade, that's dist hyphen upgrade,
to upgrade your entire distribution to a new version.
Sometimes packages are installed as dependencies
but no longer required.
Apt will tell you about it.
And then you can use apt autoremove to remove them.
And finally, if you are looking for a specific package,
then you can use apt-cache search on a filename.
That will show you packages that contain a specific file.
It's kind of the equivalent to yum provides.
Let me demonstrate.
All right, so the first thing I'm going to do
is sudo apt update.
Sudo apt update, make sure that we update the package cache.
In this procedure, it's contacting the repositories,
and it is making sure that the most recent index files
from the repositories are fetched,
so that we can easily install packages,
and we have all the information that we need
available locally.
You can see that apt update
is automatically analyzing for me what is going on.
And it even makes a suggestion,
that is use apt list --upgradeable,
because there are packages that seem to be upgradeable.
So all of this is what I can upgrade.
I'll tell you, I will do the upgrade in just a little bit.
All right, let's go start and use sudo apt search
to search for packages based on nmap, for instance.
Now what do we see?
We see too much information right here, honestly.
I mean, let's pipe it through wc.
I like wc, that's word count.
101 lines, who is ever going to read 101 lines?
Does it help to have a look only at the top of the output?
And there we see that doesn't even help.
I'm looking for my nmap package, but I can't find it.
So let me do a sudo apt-cache search on nmap,
which is going to search in the apt cache,
and which is producing a list of packages
that is a lot easier to work with.
So I have the nmap package, and that is okay.
Let's install it, sudo apt install nmap.
And that'll install the nmap package for me,
including all of the dependencies.
You can see right here,
following new packages will be installed.
And of course I want to continue,
because that is what I've been asking for, right?
So there we go.
Now one other thing that you might want to do frequently
with apt is sudo apt upgrade.
So sudo apt upgrade is upgrading packages.
Only one megabyte, that is doable.
So let's do it.
And it'll upgrade these packages for me.
Especially if you are not in the LTS version of Ubuntu,
or in my case, I'm in the daily build version
of the Ubuntu 22.04, then it is useful
to do upgrades and do upgrades a lot,
so that you have access to the latest and greatest software.
Do keep in mind, though,
that doesn't always match the security policy
used by companies.
Some companies need to verify the packages
before any upgrades can be done.
All right, and with that,
I think we've seen enough about apt.