No. 4. LINUX Basics for Hackers (Adding and Removing Software)

10 July 2023 13 minutes Author: Lady Liberty

Easy software management in Linux

The Linux operating system offers a variety of tools to easily add and remove software. With a variety of methods and commands, Linux users can quickly install new programs and safely remove redundant software. In our handy guide, we’ll show you how to easily manage programs on your Linux system. Adding software: Using a package manager: Linux provides package managers that allow you to conveniently install programs from official repositories. You can use commands or the graphical interfaces of package managers to find, select, and install the programs you need. Using Software Center: Many Linux distributions have a graphical Software Center. You can simply open the software center, browse the available apps and install them with a few clicks.

Uninstalling software: Using a package manager: Package managers also make it easy to uninstall programs that you no longer need. With the help of the appropriate commands in the terminal, you can remove programs along with their dependencies, which frees up space on your system. Using the Software Center: The graphical Software Center also has the ability to uninstall programs. You can view the installed programs and perform the uninstallation operation with just a few mouse clicks. Reminder: Always back up important data before adding or removing software to avoid data loss or system problems. Conclusion: Thanks to the wide range of tools in Linux, adding and removing software is made easy with the commands of package managers or the graphical interfaces of the software center. Enjoy a wide selection of applications and easy management of your Linux system with the help of our helpful guide.

Using APT to work with software

On Debian-based Linux distributions, which include Kali and Ubuntu, the default software manager is the Advanced Packaging Tool, or apt, whose primary command is apt-get. At its simplest and most common, you can use apt-get to download and install new software packages, but you can also update and update software with it.

Parcel search

Before you download a software package, you can check whether the package you need is available from your repository, which is where your operating system stores information. The apt tool has a search function that can check if a package is available.

The syntax is simple:

Search keyword aptcache

Note that we use  the apt-cache command to find the apt cache or where the package names are stored. So, if you were to search for the intrusion detection system Snort, for example, you would enter the command shown in Listing 41.

kali >apt-cachesearchsnort
fwsnort ­ Snort­to­iptables rule translator
ippl ­ IP protocols logger
--snip--
snort ­ flexible Network Intrusion Detection System
snort­common ­ flexible Network Intrusion Detection System ­ common files
--snip--
Listing 4­1: Searching the system with apt-cachefor Snort

As you can see, numerous files have the snort keyword, but near the middle of the output we see snort, a flexible network intrusion detection system. That’s what we’re looking for!

Adding software

Now that you know the snort package exists in your repository, you can use apt-get to download the software.

To install a piece of software from the default operating system repository in a terminal, use the apt-get command, followed by the keyword install, followed by the name of the package you want to install.

The syntax looks like this:

aptget install packagename

Let’s try this by installing Snort on your system. Enter apt-get install snort  as a command line as shown in Listing 42.

kali >apt-getinstallsnort
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
snort­doc
The following NEW packages will be installed:
snort
­­snip­­
Install these packages without verification [Y/n]?
Listing 4­2: Installing Snort with apt-getinstall

The output you see tells you what is being installed. If everything looks correct, type y when prompted and the software installation will continue.

Uninstalling software

When uninstalling software, use apt-get with the uninstall option followed by the name of the software you want to uninstall (see Listing 43)

kali >apt-getremovesnort
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer
required:
libdaq0 libprelude2 oinkmaster snort­common­libraries snort­rules­default
­­snip­­
Do you want to continue [Y/n]?
Listing 4­3: Removing Snort with apt-getremove

Again, you’ll see the tasks in progress in real time and you’ll be asked if you want to continue. You can type y to remove, but you can keep Snort since we will be using it again. The remove command does not remove configuration files, which means that you can reinstall the same package in the future without reconfiguration.

If you want to remove the configuration files at the same time as the package, you can use  the purge option as shown in Listing 44.

kali >apt-getpurge snort
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libdaq0 libprelude2 oinkmaster snort­common­libraries snort­rules­default
­­snip­­
Do you want to continue [Y/n]?
Listing 4­4: Removing Snort and the accompanying configuration files with apt-get
purge

Just type Y at the prompt to continue cleaning the software package and configuration files.

You may have noticed the line The following packages were automatically installed and are no longer needed in the output. To keep things small and modular, many Linux packages are broken up into software blocks that can be used by many different applications. When you installed Snort, you installed with it several dependencies or libraries that Snort needs to run. Now, when you uninstall Snort, these other libraries or dependencies are no longer needed, so they are removed as well.

Update packages

The software repositories will be periodically updated with new software or new versions of existing software. These updates do not come to you automatically, so you must request them to apply these updates to your own system. An update is not the same as an update: an update simply updates the list of packages available for download from the repository, while an upgrade updates a package to the latest version in the repository.

You can update your individual system by typing apt-get followed by the update keyword. This will allow you to view all the packages on your system and check if updates are available. If so, updates are downloaded (see Listing 45).

kali >apt-getupdate
Get:1 http://mirrors.ocf.berkeley.edu/kali kali­rolling InRelease [30.5kb]
Get:2 http://mirrors.ocf.berkeley.edu/kali kali­rolling/main amd64 Packages
[14.9MB]
Get:3 http://mirrors.ocf.berkeley.edu/kali kali­rolling non­free amd64 Packages
[163kb]
Get:4 http://mirrors.ocf.berkeley.edu/kali kali­rolling/contrib amd64 Packages [107
kB]
Fetched 15.2 MB in 1min 4s (236 kB/s)
Reading package lists... Done
Listing 4­5: Updating all out­of­date packages with apt-getupdate

The list of available software in your system’s repository will be updated. If the update is successful, your terminal will say Read Package Lists… Done, as you can see in Listing 45. Note that the repository name and values—time, size, etc.—may be different on your system.

Update packages

To upgrade existing packages on your system, use apt-get upgrade. Because upgrading your packages can make changes to your software, you must be logged in as root or use the sudo command before typing apt-get upgrade. This command will update every package on your system that apt knows about, that is, only those stored in the repository (see Listing 46). The update may take a long time, so you may not be able to use the system for some time.

kali >apt-getupgrade
Reading package lists... Done
Building dependency tree... Done
Calculating upgrade... Done
The following packages were automatically installed and no longer required:
­­snip­­
The following packages will be upgraded:
­­snip­­
1101 upgraded, 0 newly installed, 0 to remove and 318 not upgraded.
Need to get 827 MB of archives.
After this operation, 408 MB disk space will be freed.
Do you want to continue? [Y/n]
Listing 4­6: Upgrading all out­of­date packages with apt-getupgrad

You should see in the output that your system estimates the amount of hard disk space required for the software package. Enter Y if you want to continue and have enough hard drive space for the update.

Adding repositories to your sources. List file

Servers that store software for specific Linux distributions are known as repositories. Almost every distribution has its own repositories of software—developed and customized for that distribution—that may not work well or at all with other distributions. Although these repositories often contain the same or similar software, they are not identical, and sometimes they contain different versions of the same software or completely different software.

You will of course be using the Kali repository which has a lot of security and hacking software. But since Kali specializes in security and hacking, it does not include some special software and tools and even some runofthemill software. It’s worth adding a fallback repository or two that your system can search if it doesn’t find a specific software in the Kali repository.

The repositories that your system will search for software are stored in the sources.list file, and you can modify this file to determine which repositories you want to download software from. I often add the Ubuntu repositories after the Kali repositories in my sources.list file; that way, when I ask to download a new software package, my system will first look in the Kali repository, and if the software package is not there, it will look in the Ubuntu repository.

You can find the sources.list file at /etc/apt/sources.list and open it with any text editor. I will be using Leafpad again. To open the sources.list file, type the following into your terminal.

By replacing listpad with the name of your editor:

kali > leafpad /etc/apt/sources.list

After entering this command, you will see a window similar to the one in Figure 41, listing the default Kali repositories.

Figure 41: Typical Kali repositories in sources.list

Many Linux distributions divide repositories into separate categories. For example, Ubuntu breaks down its storage categories as follows:

Home Contains supported open source software Contains community supported open source software Multiverse Contains software restricted by copyright or other legal issues Contains proprietary device drivers Backports Contains packages from later releases

I don’t recommend using test, experimental, or unstable repositories in your sources.list because they can download problematic software to your system. Software that is not fully tested can break your system.

When you request to download a new software package, the system sequentially scans your repositories listed in sources.list and stops when it finds the package you want. First, make sure the storage is compatible with your system. Kali, like Ubuntu, is built on Debian, so these repositories work quite well with each of those systems.

To add a repository, simply edit the sources.list file to add the repository name to the list, then save the file. Let’s say for example you want to install Oracle Java 8 on Kali. No apt package for Oracle Java 8 is available as part of the standard Kali sources, but a quick web search reveals that the fine folks at WebUpd8 have created one. If you add their repository to the sources, you can install Oracle Java 8 using the apt-get install oracle-java8-installer command. At the time of writing, you will need to add the following repository locations to sources.list to add the required repositories:

  • deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main

  • deb­src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main

Using a GUI-based installer

Newer versions of Kali no longer include a GUI-based software installer, but you can always install it using  the apt-get command. The two most common GUI-based installers are Synaptic and Gdebi. Let’s install Synaptic and use it to install our Snort package:

kali >apt-getinstallsynaptic
Reading package lists... Done
Building dependency tree
Reading state information... Done
­­snip­­
Processing triggers for menu (2.1.47)...
kali >

Once Synaptic is installed, it can be launched from Preferences ▸ Synaptic Package Manager, which should open a window similar to the one in Figure 42.

Figure 42: Synaptic package manager interface

Now you can search for the package you are looking for. Just click the Search tab to open the search box. Since you are searching for Snort again, type snort  in the search box and click Search. Scroll down through the search results to find the package you’re looking for. Select the check box next to snort and then click the Apply tab as shown in Figure 43. Synaptic will now download and install Snort from the repository along with all required dependencies.

Figure 43: Downloading Snort from the Synaptic package manager

Installing software using GIT

Sometimes the software you need is not available in any of the repositories, especially if it is brand new, but it may be available on github (https://www.github.com/), a site that allows developers to share their software with others to download , use and provide feedback. For example, if you need bluediving, a Bluetooth hacking and testing kit, and you can’t find it in the Kali repository, you can find the software on github by typing bluediving into the search bar. If it exists on github, you should see a repository for it in the search results.

Once you find the software on github, you can install it from the terminal by typing git clone followed by the github URL. For example, bluediving is at https://www.github.com/balle/bluediving.git. To clone it on your system, enter the command shown in Listing 47.

kali >gitclonehttps://www.github.com/balle/bluediving.git
Cloning into 'bluediving'...
remote: Counting objects: 131, Done.
remote: Total 131 (delta 0), reused 0 (delta 0), pack­reused 131
Receiving objects: 100% (131/131), 900.81 KiB | 646.00 KiB/s, Done.
Resolving deltas: 100% (9/9), Done.
Checking connectivity... Done.
Listing 4­7: Cloning bluediving with gitclone

Listing 47: Cloning disk diving with git clone

The git clone command copies all data and files from this location to your system. You can check if they are loaded successfully by using the ls –l long list command in the target directory, for example:

If >ls -l

If you have successfully cloned diskdiving to your system, you should see the following output:

total 80
drwxr­xr­x 7 root root 4096 Jan 10 22:19 bluediving
drwxr­xr­x 2 root root 4096 Dec 5 11:17 Desktop
drwxr­xr­x 2 root root 4096 Dec 5 11:17 Documents
drwxr­xr­x 2 root root 4096 Dec 5 11:17 Downloads
drwxr­xr­x 2 root root 4096 Dec 5 11:17 Music
­­snip­

As you can see, bluediving has been successfully cloned into the system and a new directory called bluediving has been created for its files.

Summary

In this chapter, you learned a few of the many ways to download and install new software on your Linux system. Software package managers (such as apt), GUI-based installers, and git clones are the most common and important techniques that a novice hacker should know. You will soon get to know each of them.

We used materials from the book “LINUX BASICS FOR HACKERS” written by William Pollock

Other related articles
Found an error?
If you find an error, take a screenshot and send it to the bot.