The most common method of installing apps on Linux is from the repositories using a package manager. The principle is more or less the same everywhere, the main difference being the package management system of a particular distribution. Sound a bit Greek to you? Here’s an explanation.

What Is a Package Management System?

Linux software is usually distributed in the form of packages. In simplified terms, a package management system refers to the tools and file formats required to manage those packages. Two most widespread package management systems are dpkg (uses .deb files) and RPM (its packages are .rpm files). The difference between package management systems is generally in their approach to the installation process (for example, RPM packages can depend on files, rather than other packages).

Linux packages are just archive files (like .zip and .rar) that contain the application code and the instructions on how to install the application, where to place its configuration files, and what other packages it requires. The software that executes those instructions is called a package manager.

Tip: Always make sure to use the right package format for your distribution. If you can’t find a .deb package of an application, but a .rpm one is available, it’s possible to convert between them.

Every Linux distribution comes with a package manager. If you don’t like the default one, you can replace it (provided that the new one supports your distro’s package format). The package manager is where you’ll search for, install, update, and remove applications. It can have a command-line or a full graphical interface, and it stores the information about installed applications, their versions, and dependencies in a local database. This helps it clean up all the “leftovers” automatically after you uninstall an app.

What Is a Repository?

Of course, your package manager can’t just produce packages out of thin air. It needs to fetch information about available packages from a location called the repository. It’s a collection of packages for a particular Linux distribution. The repository can be a network location, a local storage unit (a DVD, a USB drive, or a hard drive), or even a single file. Every distribution has its official repositories with thousands of packages.

If an app is unavailable in the official repositories (or you just want the newest version straight from the developers), you can add new repositories to your system. Make sure to choose the repository that matches your distribution’s version. New repositories can be added via a dialog in your package manager, or by editing files with admin privileges.

Dpkg-based distributions store their repository information in the /etc/apt/sources.list file or in separate .list files in the /etc/apt/sources.list.d/ directory.

For RPM distros, you can add new repositories under the [repository] section in the /etc/yum.conf file (or /etc/dnf/dnf.conf, if you use DNF instead of Yum), or create .repo files in the /etc/yum.repos.d/ directory.

Tip: If you don’t want to upgrade your Linux distribution, but still want to receive software updates, look for repositories labeled as “backports”. They contain new versions of apps for old versions of a distribution.

How to Install Linux Apps

1. From the Terminal

A long time ago, this was the only way to install Linux apps. Package managers didn’t have handy checkboxes and menus; they were command-line utilities. They still exist today – in fact, you use them every time you install something with a graphical package manager, since it’s just a front-end for the command-line tool. You can use them directly if you want to speed things up, or if you simply prefer using the terminal.

Dpkg is the name of the package management system, but also of the basic tool for handling .deb packages. It’s sometimes referred to as a “low-level” tool, and all other package utilities build upon its functionality. You can use it to install a single .deb package:

sudo dpkg -i packagename.deb

where -i stands for “install”. Dpkg cannot automatically resolve dependencies, but it can (re)configure packages and extract their content.

APT (Advanced Package Tool) has all the features of dpkg, and then some. It comprises several tools, such as apt-get, apt-cache, apt-add-repository, apt-file… To install applications, you need apt-get:

sudo apt-get install packagename

Another useful feature is simulation:

sudo apt-get install packagename -s

It shows you which packages will be added or removed, and which files will be configured, but it doesn’t actually install anything.

Aptitude improves upon dpkg and APT, introducing a graphical interface in the terminal, which you either love or hate.

You can install apps from this interface or by typing commands:

sudo aptitude install packagename

Aptitude is similar to apt-get, but it provides more information and guidance while you manage packages. It treats automatically installed packages and system upgrades a little differently than apt-get does, and it offers advanced search options. Aptitude can warn you about conflicts when installing or removing packages, and show which packages are causing a problem thanks to the why command.

The situation is analogous on RPM-based distributions: the rpm command-line utility is roughly equivalent to dpkg, your APT is their Yum, and aptitude corresponds to DNF.

DNF stands for Dandified Yum, a new version of Yum that was introduced in Fedora 18. Both Yum and DNF can automatically resolve dependencies. The syntax for installing packages is simple and almost exactly the same with each tool:

Mageia has its own wrapper for rpm called urpmi with equally simple commands for installation:

urpmi packagename

and searching:

urpmq packagename
urpmq -y keyword

On Arch Linux, you can use the default package manager (pacman) to install packages:

pacman -S packagename

and search for applications in the repositories:

pacman -Ss keyword

However, if you want to install something from the AUR (Arch User Repository), you need a separate tool called an AUR helper. AUR doesn’t contain binary packages that pacman can manage; instead, it’s a repository of “recipes” for applications that have to be built manually. Yaourt is one of the most popular command-line AUR helpers because it can install both “regular” Arch Linux packages as well as those from AUR. It’s interactive, so you can type:

yaourt keyword

and it will display the results as a numbered list. After you pick a number, Yaourt asks you what to do with the package. Alternatively, you can just type:

yaourt -S packagename

to install the desired package. Yaourt takes care of the dependencies automatically.

2. With a Graphical Package Manager

This is the recommended way to install Linux apps. Just fire up your package manager, find a package, mark it for installation, and confirm changes. You’ll be asked for the administrator password, so type it correctly.

The package manager will occasionally select several packages for installation. Those are your application’s dependencies – other packages that it requires to work properly. Some package managers will “recommend” and mark related (but not obligatory) packages for installation. It’s possible to disable this behavior in the Settings/Preferences dialog.

Dpkg-based distributions usually ship Synaptic as the default package manager, though some offer Muon:

Ubuntu Software Center will be replaced by Gnome Software in the April 2016 release (Ubuntu 16.04). Linux Mint offers Synaptic and its own product called Software Manager.

On Arch Linux, you can use Pamac or Octopi as a graphical alternative to yaourt:

Both tools can search and install packages from the official repositories as well as from the AUR.

Tip: If you want to install a new desktop environment or an office suite, look for its metapackage in the package manager. It’s much easier to install one metapackage than hunt for dozens of individual packages.

3. Use GDebi and Wajig

Users of dpkg-based distributions can play with two interesting tools. GDebi is a front-end for APT that lets you install an application by double-clicking a .deb file. Unlike dpkg, GDebi can automatically install missing dependencies. It’s particularly useful when you want to install an app that’s not in the repositories, but you’ve downloaded its .deb file.

Wajig combines the powers of dpkg, apt-get, apt-cache, and a bunch of other tools. Apart from installing apps and upgrading the system, Wajig can stop or start system services, convert RPM packages, and provide detailed information about all packages in the repositories.

Tip: You can set GDebi as the default application for opening .deb files. Right-click a .deb file, select the Open with… option, find GDebi in the list, and confirm changes. Now your .deb files behave like .exe installers from Windows.

4. With a Self-Installer

This method applies to software that’s not in the repositories and has to be downloaded from the developer’s website instead, such as proprietary drivers. In some cases, this software is distributed as a self-extracting file with a .run or .bin extension. To install it, right-click the file to access its Properties > Permissions dialog and mark it as executable.

Now you can either double-click the file to start the installation, or navigate to it in the terminal and type ./filename.run. The installation will proceed automatically and the dialogs will look very similar to Windows installers.

Tip: Self-installers can also be bash scripts (files with the .sh extension). You can run them in the terminal by typing ./filename.sh.

5. Compile Them From Source

It’s rare, but it happens. Sometimes the developers won’t package an application for any distribution, instead providing the source code that you need to compile yourself. The source should be a .tar archive file which you have to unpack. It contains helpful files called README and/or INSTALL, so consult them first. The general “recipe” for compiling apps includes the following commands:

7) Use Application-Level Package Managers

If you want to get geeky, you can use application-level package managers alongside your default, system-level package manager. The former are also known as programming language package managers. They contain libraries and supporting utilities for a programming language, so if an application is written in that language, it can be easily distributed and installed with the package manager.

There are quite a few of them: pip for Python, RubyGems for Ruby, npm for Node.js, NuGet for the Microsoft development platform… Some apps are much easier to install with this type of package manager because of a large number of dependencies that might not be available in your distro’s repositories.

As you can see, there are several ways to install apps on Linux, each with its own (dis)advantages. When in doubt, use the package manager, but don’t forget there are other options. After all, it’s the variety of options that makes Linux so awesome.

What is your preferred method of installing Linux apps? Do you have any tips for Linux beginners? Share your thoughts in the comments below.

Ivana Isadora is a freelance writer and translator, Linux lover and KDE fangirl. She supports and promotes free & open source software, and she's always looking for fresh, innovative apps. Find out how to get in touch here.