How to install software from the Linux command line

Learn the different types of package managers and how to use them.
316 readers like this.
A guide to packing and preparing for a tech conference

Opensource.com

If you use Linux for any amount of time, you'll soon learn there are many different ways to do the same thing. This includes installing applications on a Linux machine via the command line. I have been a Linux user for roughly 25 years, and time and time again I find myself going back to the command line to install my apps.

The most common method of installing apps from the command line is through software repositories (a place where software is stored) using what's called a package manager. All Linux apps are distributed as packages, which are nothing more than files associated with a package management system. Every Linux distribution comes with a package management system, but they are not all the same.

What is a package management system?

A package management system is comprised of sets of tools and file formats that are used together to install, update, and uninstall Linux apps. The two most common package management systems are from Red Hat and Debian. Red Hat, CentOS, and Fedora all use the rpm system (.rpm files), while Debian, Ubuntu, Mint, and Ubuntu use dpkg (.deb files). Gentoo Linux uses a system called Portage, and Arch Linux uses nothing but tarballs (.tar files). The primary difference between these systems is how they install and maintain apps.

You might be wondering what's inside an .rpm, .deb, or .tar file. You might be surprised to learn that all are nothing more than plain old archive files (like .zip) that contain an application's code, instructions on how to install it, dependencies (what other apps it may depend on), and where its configuration files should be placed. The software that reads and executes all of those instructions is called a package manager.

Debian, Ubuntu, Mint, and others

Debian, Ubuntu, Mint, and other Debian-based distributions all use .deb files and the dpkg package management system. There are two ways to install apps via this system. You can use the apt application to install from a repository, or you can use the dpkg app to install apps from .deb files. Let's take a look at how to do both.

Installing apps using apt is as easy as:

$ sudo apt install app_name

Uninstalling an app via apt is also super easy:

$ sudo apt remove app_name

To upgrade your installed apps, you'll first need to update the app repository:

$ sudo apt update

Once finished, you can update any apps that need updating with the following:

$ sudo apt upgrade

What if you want to update only a single app? No problem.

$ sudo apt update app_name

Finally, let's say the app you want to install is not available in the Debian repository, but it is available as a .deb download. You can install it manually using dpkg, the system that apt helps manage:

$ sudo dpkg -i app_name.deb

RHEL, CentOS, Fedora, Mageia, and OpenMandriva

Red Hat, its upstream project Fedora, and its "midstream" project CentOS, use the dnf package manager. It has its own syntax, and is a front-end to the RPM system. Although the syntax is different, dnf is similar to apt in the sense that the mechanisms and goals are the same. The Mageia and OpenMandriva distributions, once focused exclusively on urpmi for package management, now also  includes dnf in their distributions.

The dnf package manager is the successor to the previous yum command. The yum had a long time to engrain itself in the minds and servers of users, so to avoid breaking custom scripts that have been around on users' systems for over a decade, yum and dnf are now interchangeable (in fact, yum is now based on dnf.)

To install an app:

$ sudo dnf install app_name

Removing unwanted applications is just as easy.

$ sudo dnf remove app_name

Updating apps:

$ sudo dnf upgrade --refresh

The dnf (or yum) command is a front-end for the RPM packaging system. If you can't find an app in your software repository but you can find it for download directly from its vendor site, you can use dnf to manually install an .rpm file.

$ sudo dnf install ./app_name.rpm

As you can see, installing, uninstalling, and updating Linux apps from the command line isn't hard at all. In fact, once you get used to it, you'll find it's faster than using desktop GUI-based management tools!

For more information on installing apps from the command line, please visit the Debian Apt wiki, the Yum cheat sheet, and the DNF wiki.

User profile image.
Hello! I'm Patrick, and I'm a retired IT Engineer, former IBMer, Writer, Open Source advocate, Gamer, and self-proclaimed super geek. I'm also big into space technologies and exploration, UNIX, the command-line, retro consoles, and retro computers like the Atari 2600, Commodore 64, and the Amiga.

Contributors

1 Comment

One of the things I like about dnf is that you can also install RPMs that you have saved to your drive -- they don't have to be in some repository somewhere. The advantage of using dnf is that it will check for and install any needed dependencies.

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.