The first task you may want to perform is updating all the metadata in your local
package database. These are the details about the packages that the remote reposito‐
ries have, including version numbers. The version information is needed to deter‐
mine whether the software you have is out-of-date and in need of upgrading. To
update your local package database, you tell
apt
you want to update, as you can see in
Example 1-7
.
Example 1-7. Updating package database using apt
root@rosebud:~# apt update
Get:1 http://kali.localmsp.org/kali kali-rolling InRelease [30.5 kB]
Get:2 http://kali.localmsp.org/kali kali-rolling/main amd64 Packages [15.5 MB]
Get:3 http://kali.localmsp.org/kali kali-rolling/non-free amd64 Packages [166 kB]
Get:4 http://kali.localmsp.org/kali kali-rolling/contrib amd64 Packages [111 kB]
Fetched 15.8 MB in 2s (6437 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
142 packages can be upgraded. Run 'apt list --upgradable' to see them.
Once your local package database has been updated,
apt
will tell you whether you
have updates to what you have installed.
In this case, 142 packages are in need of
updating. To update all the software on your system, you can use
apt upgrade
. Just
using
apt upgrade
will update all the packages. If you need to update just a single
package, you can use
apt upgrade packagename
, where
packagename
is the name of
the package you want to update. The packaging format used by Debian and, by exten‐
sion, Kali, tells
apt
what the required packages are. This list
of dependencies tells Kali
what needs to be installed for a particular package to work. In the case of upgrading
software, it helps to determine the order in which packages should be upgraded.
If you need to install software, it’s as easy as typing
apt install packagename
. Again,
the dependencies are important here.
apt
will determine
what software needs to be
installed ahead of the package you are asking for. As a result, when you are asking for
a piece of software to be installed,
apt
will tell you that other software is needed. You
will get a list of all the necessary software and be asked whether you want to install all
of it. You may also get a list of optional software packages.
Packages may have a list of
related software that can be used with the packages you are installing. If you want to
install them, you will have to tell
apt
separately that you want to install them. The
optional packages are not required at all.
Removing packages uses
apt remove packagename
. One of the issues with removing
software is that although there are
dependencies for installation, the same software
may not necessarily get removed—simply because once it’s installed, it may be used
by other software packages.
apt
will, though, determine whether software packages
are no longer in use. When you
perform a function using
apt
, it may tell you that