Installing Software

Packages

A package in the linux distributions is a compressed archive that contains all necessary files for a software to run in the system.

This includes among others:

  • Binaries
  • Configuration files
  • Metadata
Dependencies

The compressed package does not include other software that it needs to run. This “dependencies” are the main reason package managers exist

Package managers

Package managers help with the following when dealing with packages:

  • Installation (Decompression, copying files)
  • Upgrading
  • Configuration
  • Removal
  • Integrity checks (comes from a trusted source, checksum check, etc.)
  • Deal with dependencies

Here is a general overview of the common managers used to install packages on different Linux distributions:

  • Debian and Ubuntu: Software is typically installed using the apt package manager. Low level manager is normally dpkg
  • Red Hat and Fedora: Software is typically installed using the yum or dnf package manager. Low level manager is normally rpm
  • SUSE Family: Software is typically installed using the zypper package manager. Low level manager is normally rpm
  • Other distributions: Some other Linux distributions, such as Slackware, use their own package management systems.

As seen above, all linux distributions have a low level and a high level package manager:

  • The low level, is in charge of installing single packages correctly.
  • The high level usually calls the low level one and additionally, is in charge of resolving dependencies.
Other ways of installing

It’s also worth noting that there are other ways to install software on Linux, such as downloading binaries, compiling from source code, using flatpak, or using snap which is increasingly popular, but package managers are the most common and recommended method.

Common operations

OperationRH FamilyDebian Family
Install packagerpm -i foo.rpmdpkg -i foo.deb
Install package, dependenciesyum/dnf install fooapt-get install foo or apt install foo
Remove packagerpm -e foo.rpmdpkg -r foo.deb
Remove package, dependenciesyum/dnf remove fooapt-get remove foo or apt remove foo
Remove package, deps, and configapt-get remove --purge foo or apt purge foo
Remove “left-behind” packagesyum/dnf autoremoveapt-get autoremove or apt autoremove
Update packagerpm -U foo.rpmdpkg -i foo.deb
Update package, dependenciesyum/dnf update fooapt-get install foo
Update entire systemyum/dnf updateapt upgrade to upgrade all packages, apt-get dist-upgrade to upgrade OS as well
Show all installed packagesrpm -qa or yum/dnf list installeddpkg -l or apt list --installed
Get information on packagerpm -qil foo``dpkg -s foofor status,dpkg –listfiles foo` to see the package files
Show packages named fooyum/dnf list "foo"apt-cache search foo or apt search foo
Show all available packagesyum/dnf listapt-cache dumpavail foo
What package is file part of?rpm -qf filedpkg --search file
Edit repository sourcesapt edit-sources
Dry run install to check for conflictsrpm -i --test-
What package provides a commandrpm --whatprovides x or yum/dnf provides x-

Debian-based distributions

APT and APT-GET

apt and apt-get are both package management tools for Debian and Ubuntu-based Linux distributions but apt is a more user-friendly tool, abstracting some of the functionality from other commands. apt-get is considered to be more powerful and flexible, and mostly used in automation for the -y option for example.

Repositories

apt (or apt-get) stores a list of repositories or software channels in the file /etc/apt/sources.list and in any file with the suffix .list under the directory /etc/apt/sources.list.d/

A software repository is a collection of software packages that can be installed on the system. These packages are organized and managed by Ubuntu developers and are easily accessible to users via the apt package manager.

By editing these files from the command line, we can add, remove, or temporarily disable software repositories.

Format

A typical line on the file looks like this:

deb http://ch.archive.ubuntu.com/ubuntu/ saucy main restricted
  • deb: These repositories contain binaries or precompiled packages. These repositories are required for most users.
  • deb-src: These repositories contain the source code of the packages. Useful for developers.
  • http://archive.ubuntu.com/ubuntu: The URI (Uniform Resource Identifier), in this case a location on the internet.
  • saucy is the release name or version of the distribution (found with lsb_release -sc).
  • main & restricted are the section names or components. There can be several section names, separated by spaces.

Adding new repositories

Adding a new line with the above format will add a new repository. To “load” them is important to retrieve the updated package list with

sudo apt-get update
PPA Repositories

Adding Launchpad PPA (Personal Package Archive) is possible conveniently via the command add-apt-repository in Ubuntu or addrepo on Debian. It looks like: sudo add-apt-repository ppa:<repository-name>