What is a package
A package is a software which consists of a collection of files on your Kali Linux to perform a task.
dpkg
dpkg is the core tool package installation – either directly or through Advanced Package Tool (APT).
To display a list of what packages are currently installed on the machine, you can use dpkg --get-selections command.
┌──(kaliă‰¿kali)-[~/Documents/TRAINING]
└─$ dpkg --get-selections
acl install
adduser install
adwaita-icon-theme install
aircrack-ng install
alsa-topology-conf install
alsa-ucm-conf install
amass install
amass-common install
...
Advanced Package Tool (APT)
With APT on Debian-based distributions, you can manage packages. Because Kali Linux is based on Debian, we can employ APT to install, remove, update, and upgrade packages. APT – as opposed to dpkg – will also install any dependencies that a package might require.
Exercise
With tree being installed and checking its manual page, explain what it does; then, run it against your home directory.
apt update
Always update the list of all packages in the cache. Here is an exert from man page of apt-get
update Used to re-synchronize the package index files from their sources. The indexes of available packages are fetched from the location(s) specified in /etc/apt/sources.list(5). You should perform an update always before an upgrade or dist-upgrade.
┌──(kaliă‰¿kali)-[~]
└─$ sudo apt update
[sudo] password for kali:
Get:1 http://mirrors.ocf.berkeley.edu/kali kali-rolling InRelease [30.6 kB]
Get:2 http://mirrors.ocf.berkeley.edu/kali kali-rolling/main amd64 Packages [18.1 MB]
Get:3 http://mirrors.ocf.berkeley.edu/kali kali-rolling/main amd64 Contents (deb) [41.6 MB]
85% [2 Packages store 0 B] [3 Contents-amd64 34.0 MB/41.6 MB 82%] 4,237 kB/s 2s
apt upgrade
Using apt upgrade, which should come after apt update, we upgrade the installed packages to the latest version.
┌──(kaliă‰¿kali)-[~]
└─$ sudo apt upgrade
[sudo] password for kali:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
apt install
Using apt install, you can install packages on your Kali Linux. For example:
┌──(kaliă‰¿kali)-[~]
└─$ sudo apt install tree
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
tree
0 upgraded, 1 newly installed, 0 to remove and 762 not upgraded.
Need to get 55.4 kB of archives.
After this operation, 124 kB of additional disk space will be used.
Get:1 http://mirrors.ocf.berkeley.edu/kali kali-rolling/main amd64 tree amd64 2.0.2-1 [55.4 kB]
Fetched 55.4 kB in 1s (37.9 kB/s)
Selecting previously unselected package tree.
(Reading database ... 289318 files and directories currently installed.)
Preparing to unpack .../tree_2.0.2-1_amd64.deb ...
Unpacking tree (2.0.2-1) ...
Setting up tree (2.0.2-1) ...
Processing triggers for man-db (2.9.4-4) ...
Processing triggers for kali-menu (2021.4.2) ...
apt remove
The command apt remove --purge will remove the packages from your Kali Linux. --purge is for removing the dependencies of the package. For example:
┌──(kaliă‰¿kali)-[~]
└─$ sudo apt remove --purge nano
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
nano*
0 upgraded, 0 newly installed, 1 to remove and 761 not upgraded.
After this operation, 2,804 kB disk space will be freed.
Do you want to continue? [Y/n]