An intro to adding and removing software in Debian-based Linux distributions

In Debian-based Linux distributions, the default software manager is the Advanced Packaging Tool, apt.

Let's take a look at

apt-cache search
apt-get install
apt-get remove
apt-get purge 
apt-get update
apt-get upgrade
/etc/apt/sources.list

The apt-cache search command

Servers that hold the software for particular distributions of Linux are known as repositories. The repositories your system will search in are stored in the sources.list file. To check if a package is available for you to download:

apt-cache search keyword

Let's search for the snort keyword

apt-cache search snort

Several options were returned, it's up to us to make sure we select the correct one to install.

The apt-get install command

Once we know which package we want to install, we can use

apt-get install packagename

to install it, let's install the snort - flexible network intrusion detection system package, from our previous command results.

apt-get install snort

Snort is already installed on my machine so I am not asked Y/n to install it, output might be different for you.

The apt-get remove command

If you need to remove a command, use:

apt-get remove packagename

The remove command doesn't remove configuration files, for that we use purge.

The apt-get purge command

To keep things modular, many Linux packages are broken into software units that many different programs can share. When you install a package, you also install any dependencies or libraries it needs to run, in order to remove all those files, we use the purge command

apt-get purge packagename

If I wanted to remove snort and all it's dependencies, I can do

apt-get purge snort

I don't want to, but you get the idea.

The apt-get update command

It's used to search through all the packages on your system and check if updates are available for them, if so, it downloads the updates.

apt-get update

Now how do we actually install these updates?

The apt-get upgrade command

This command will upgrade every package on your system that apt knows about

apt-get upgrade

You'll get an estimate of amount of hard drive space necessary for the upgrade. Enter Y if you want to continue.

The sources.list file

This file tells your system which repositories to search for software from. I'll use VI to view it.

vi /etc/apt/sources.list

When you download a package, apt will look sequentially through your sources.list, it stops when it finds the package.

There are a few categories for repositories

  • main: Contains supported open source software.
  • universe: Contains community-maintained open source software.
  • multiverse: Contains software restricted by copyright or other legal issues.
  • restricted: Contains proprietary device drivers.
  • backports: Contains packages from later releases.

You can add a repository by editing this file.