Let’s discuss how to search for, install, or remove tools in Kali Linux. In this post, we will be exploring the Advanced Package Tool (APT) toolset as well as other commands that are useful in performing maintenance operations on the Kali Linux OS.
APT is a set of tools that helps manage packages, or applications, on a Debian-based system. Since Kali is based on Debian, we can use APT to install and remove applications, update packages, and even upgrade the entire system. The magic of APT lies in the fact that it is a complete package management system that installs or removes the requested package by recursively satisfying its requirements and dependencies.
Let’s first check the version of Kali Linux we’re using by running “lsb_release -a” or “cat /etc/os-release“. You can also test the “uname -a” command to see your running Debian version, check if your system runs on 32 or 64-bits and some other info.
┌──(kali㉿kali)-[~] └─$ cat /etc/os-release PRETTY_NAME="Kali GNU/Linux Rolling" NAME="Kali GNU/Linux" ID=kali VERSION="2020.4" VERSION_ID="2020.4" VERSION_CODENAME="kali-rolling" ID_LIKE=debian ANSI_COLOR="1;31" HOME_URL="https://www.kali.org/" SUPPORT_URL="https://forums.kali.org/" BUG_REPORT_URL="https://bugs.kali.org/"
┌──(kali㉿kali)-[~] └─$ lsb_release -a Linux kali 5.9.0-kali2-amd64 #1 SMP Debian 5.9.6-1kali1 (2020-11-11) x86_64 GNU/Linux
Now let us get the packages information from repositories. These repositories are websites that provide packages and their metadata. After getting the package information, we will locally compare them against our existing packages.
The “sudo apt update” command will download the metadata which includes information related to their versions, descriptions, etc. Just know that this command doesn’t update or upgrade any tool.
Apt upgrade or apt dist-upgrade
After the APT database has been updated, we can upgrade the installed packages to their latest versions using the “sudo apt upgrade“ command.
If you want to upgrade a single package, add the package name after the “apt upgrade“ command such as “apt upgrade python3“.
You can also upgrade the core system and the tools at the same time by running “sudo apt dist-upgrade” or an alternative is “sudo apt full-upgrade“.
After the process you can use “sudo apt autoremove“, to remove automatically installed packages (dependencies) that are no longer needed after the upgrade, it’ll save you some space.
┌──(kali㉿kali)-[~] └─$ sudo apt dist-upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
┌──(kali㉿kali)-[~] └─$ sudo apt full-upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
┌──(kali㉿kali)-[~] └─$ sudo apt autoremove Reading package lists... Done Building dependency tree Reading state information... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Apt install & apt remove
The “apt install” command can be used to add a package to the system with apt install followed by the package name.
Similarly, we can remove a package with the command “apt remove –purge“.
The apt remove –purge command completely removes packages from Kali. It is important to note that removing a package with “apt remove“ removes all package data. Usually, it leaves small (modified) user configuration files behind, in case the removal was accidental. Adding the “–purge” option removes all the leftovers.
Installing tools offline with dpkg
dpkg stands for “Debian package” and is the core tool used to install, build, remove and manage Debian packages, either directly or indirectly through APT. It is also the preferred tool to use when operating offline since it does not require an Internet connection.
Note that “dpkg” will not install any dependencies that the package might require. It is a low-level tool, whereas APT is a higher-level tool. To install a package with “dpkg“, provide the “-i” or “–install” option and the path to the .deb package file. This assumes that the .deb file of the package to install has been previously downloaded or obtained in some other way.
Let’s practice by downloading and installing Google Chrome for Kali Linux using “dpkg”. Go to the following website to download the “.deb” package for your OS.
“cd” to your Downloads/ page afterwards and sudo “dpkg -i google-chrome-stable_current_amd64.deb“. Now you should have Google Chrome on your Kali Linux.
If you’re not happy with your newly installed package, you can use “dpkg -r google-chrome-stable_current_amd64.deb” to remove it. Beware for leftovers!
Suppose we want to purge a package, a process which removes everything, including configuration files. This can be done using the “-P” option.
┌──(kali㉿kali)-[~/Downloads] └─$ sudo dpkg -i google-chrome-stable_current_amd64.deb Selecting previously unselected package google-chrome-stable. (Reading database ... 270729 files and directories currently installed.) Preparing to unpack google-chrome-stable_current_amd64.deb ... Unpacking google-chrome-stable (87.0.4280.88-1) ... Setting up google-chrome-stable (87.0.4280.88-1) ...
After installing Kali Linux, I run by default “sudo apt dist-upgrade“, followed by “sudo apt update && apt upgrade -y“, a combo you can pick to update & upgrade the existing tools on your machine and automatically saying “yes” to confirm. When it’s finished, I run “sudo apt autoremove” to remove the unnecessary files installed during the upgrade process.