In this lesson,
we're going to cover the Debian packages and APT.
Debian is one of the most prominent Linux distributions
and it has its own package manager.
There are various programs that Debian has
for managing its packages.
However, we're going to focus mainly on DPKG and APT
since there are multiple tools
that are used to manage Debian packages
from graphic and text based interfaces
to low level tools that are used to install packages.
But as I said, our focus is going to be on DPKG and APT
'cause those are clearly listed out in your exam objectives.
Now the main package management program
that Debian uses is DPKG.
The DPKG command does use .deb files as its packages.
DPKG is the command that's used to manage packages
on Debian derived distributions, including Kali Linux
that you'll use as a penetration tester.
It includes lots of different options
including -i and the package name
which is used to install the package,
r and the package name, which is used to remove
or uninstall the package,
l and the package name
which is used to list information
about the specified package.
If you don't provide a package name,
it's going to go ahead
and list all of your installed packages.
And then -s and the package name,
which is used to report about
whether a package is actually installed or not.
For example, you might go
is an Apache web server installed on the system?
And you could type in dpkg -s apache2 and hit enter,
and then find out whether or not
Apache2 is already installed.
To run the DPKG command,
simply type in dpkg, the options and the package name.
Now you may be wondering when you use DPKG
and you install a component, does it also ensure
all the necessary components are installed?
And the answer is yes.
It's one of the great things about DPKG
is that it's going to go and find all the dependencies
and install those for you
when you're using DPKG with the -i option.
Now, in addition to using DPKG,
you can also use a newer version known as APT.
Remember, DPKG was the original installer
for Debian based Linux distributions
but APT, instead is going to be a front end manager
for that DPKG system.
And much like yum is a front end manager for RPM
inside of our Red Hat based distributions,
we're going to use APT as a front end manager for DPKG
on our Debian based systems.
For a long time, APT actually used its commands
by using a hyphenated scheme.
So you might do things like apt-get
or apt-cache to be able to interact with that system.
Now there's a lot of different sub commands
that are now added into APT as well.
So if you want to install a package,
you'll simply type apt install and the package name.
This will install your packages.
If you want to remove a package,
you can then use apt remove and the package name
to uninstall that package.
Now, when you remove a package using APT,
it does leave behind its configuration files.
So this is important to know
because if you go and reinstall that package later,
a lot of those configurations will still be there for you.
Another sub command we have is the purge sub command.
You use this by typing apt purge and the package name
to uninstall the package
and remove its configuration files.
If you want to get information about a package,
you can type in apt show and the package name
to report information about that package.
If you want to know what version information
you have on a particular package,
you could type in apt version and the package name.
The apt update sub command is one that we're going to use
to update the APT database
of the different available packages that we could install.
And then if we use the upgrade sub command,
we can type in apt upgrade and the package name
to upgrade a particular software package
to the latest version.
If you want to upgrade
all of your software packages to the latest version,
you can do that by typing apt upgrade and hitting enter.
By not specifying a package name,
it tells the system you want to go ahead
and upgrade all of them.
To use APT, simply type in apt, the options,
the sub command and the package name
to be able to run APT
and interact with the different packages
using that package manager.
Now, as I said, there were some other commands
like apt-get, and apt-cache.
These commands are still functional
but they provide a lower level functionality
and have more tight, specific controls
than using the generic apt command with its sub commands.
Now, these become a little bit more confusing
because there's a lot of different options that you can do
by using the apt get or apt cache command.
Because of this, most people now rely
on the newer variants of apt install
or apt remove instead of using apt-get.
The apt-cache is how you interact
with the underlying database of the APT system.
But again, you can do much of the same things
using the other commands I just went through.
For example, if you want to display package information,
you used to be able to use apt-cache show package name,
but now you can just use apt show package name
and it will do the same thing.
Now, the last thing I want to talk about in terms of APT
is the difference between update and upgrade
because a lot of people get this confused.
The apt update command is going to be used
to update the APT database of the available packages.
This enables APT to become aware
of any new versions of software
that may now become available.
For instance, if I ran one of these projects,
I might have version 1.1 out.
When I make a code update and this becomes version 1.2,
I now can tell that to the APT system
through the repositories,
but your system won't know it until you do an APT update
where it queries the database
and says, give me all the latest information.
Now, when we're looking at
the upgrade option on the other hand,
this is actually going to be used to install new software.
Remember, apt update does not upgrade your software.
It doesn't do anything to your own system
except tell you what versions are now available.
When you're using apt upgrade though,
you're actually going and updating that software
to the newer version that you just found
inside the APT database.
This is the full upgrade of the software
and so we can actually download the latest version,
install it on our system
and use the new code and it's features
that it's going to be installing.
This is an important distinction
that you should be aware of
between apt update and apt upgrade.
Now, that being said, as a best practice,
whenever you're going to install a new piece of software,
what should you do?
Well, first, you should run apt update and hit enter.
This will tell you what the latest version is.
Then you should do apt upgrade and the package name
to upgrade your specific package
to that latest version that you just found.
If you don't do the apt update first,
you could be upgrading yourself to an older version
and not the latest version that's available.
So keep that in mind
with differences between apt update and apt upgrade.
And in general, always do an update
before you do an upgrade.