You dont have javascript enabled! Please enable it!

Day 4 OSCP | Searching, Installing and Removing Tools

Reading Time: ( Word Count: )

December 9, 2020

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.

 

Version Check

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)-[~]      └─$ lsb_release -a No LSB modules are available. Distributor ID: Kali Description: Kali GNU/Linux Rolling Release: 2020.4 Codename: kali-rolling
  ┌──(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

 

 

Apt-update

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.

  ┌──(kali㉿kali)-[~]      └─$ sudo apt update Hit:1 http://archive-4.kali.org/kali kali-rolling InRelease Reading package lists... Done Building dependency tree Reading state information... Done All packages are up to date.

 

 

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 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 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.

  ┌──(kali㉿kali)-[~]      └─$ sudo apt install gedit Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: gedit-plugins The following NEW packages will be installed: gedit 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. ...

 

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 –purgeoption removes all the leftovers.

  ┌──(kali㉿kali)-[~]      └─$ sudo apt remove --purge gedit Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: gedit-common gir1.2-gtksource-4 gir1.2-peas-1.0 libamtk-5-0 libamtk-5-common libgtksourceview-4-0 libgtksourceview-4-common libpeas-1.0-0 libpeas-common libtepl-4-0 Use 'sudo apt autoremove' to remove them. The following packages will be REMOVED: gedit* 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 2,024 kB disk space will be freed. Do you want to continue? [Y/n]

 

 

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]      └─$ ls google-chrome-stable_current_amd64.deb
  ┌──(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) ...

 

Conclusion

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.

author bio

Author bio

Hi there, my name is Aydan, and I share exciting information about cyber security and ethical hacking, a.k.a pen-testing.

Other interesting articles

Winter Vivern: “The Latest Cyber Threat Targeting European Governments”

Winter Vivern: “The Latest Cyber Threat Targeting European Governments”

Winter Vivern, an advanced persistent threat (APT) actor, has expanded its cyber espionage campaign by targeting ...
“MacStealer Malware Strikes: iCloud Keychain Data and Passwords at Risk for Apple Users”

“MacStealer Malware Strikes: iCloud Keychain Data and Passwords at Risk for Apple Users”

A new type of macOS malware called MacStealer has been discovered, capable of stealing iCloud Keychain data and ...
Cybersecurity Automation: Empowering Your Cyber Defense

Cybersecurity Automation: Empowering Your Cyber Defense

In today's digital age, cybersecurity is a top priority for organizations of all sizes and industries. As cyber ...
Will Cybersecurity Be Automated?

Will Cybersecurity Be Automated?

In recent years, there has been a growing trend toward automation in many industries, including cybersecurity. The ...
0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

error: Alert: Content is protected !!