Open Source

How to install applications from the command line using apt, dnf, and zypper

We're back with another Linux 101 entry. This time around it's how to install, update, and remove applications from the command line.

linux101hero.jpg
Image: Jack Wallen

So you're new to Linux. You know how to install applications from your distribution's software center, but now it's time to up your game and start installing from the command line. Although you can install from source, it's always best to first install using the distribution's package manager. By using this tool, you know the newly-installed app will be recognized by the system and can be easily updated But how do you do this? I am going to show you.

Installing applications with your distribution's package manager is really easy. Even if you're intimidated by the command line, this process should not, in any way, scare you away. I'm going to walk you through the process of installing and upgrading applications using apt, dnf, and zypper. I'll demonstrate installing the same software (the Thunderbird email client) across all three tools.

Let's get started.

apt

The Advanced Package Toolkit (apt) is a set of tools used for managing Debian packages (.deb files). Apt includes one of the most widely used command line tools for installing packages, apt-get. Since Thunderbird is found in the standard repositories, the installation is quite simple. We'll be using apt-get to install the package. The structure of the command is:

apt-get OPTION COMMAND PACKAGE

Most often you will run the apt-get command without options. You won't, however, find yourself running apt-get without commands. There are a number of commands available, but the most common are:

  • update - This resynchronizes the package index files from their sources
  • upgrade - This upgrades all packages installed on the system that can be found in /etc/apt/sources.list or have .list files in /etc/apt/sources.list.d
  • install - This will install the desired package
  • remove - This will remove the desired package

So, to install Thunderbird, our command would be:

apt-get install thunderbird

Chances are, you'll be issuing this command on a system that requires sudo privileges, so in order to successfully run the command, you would have to add sudo like so:

sudo apt-get install thunderbird

Thunderbird would install and you're ready to go. Once installed, if you want to update it, simply issue the install command again. To remove Thunderbird, issue the command:

sudo apt-get remove thunderbird

dnf

The dnf system is the Fedora replacement for yum. Believe it or not, dnf is used in similar fashion to that of apt. The structure of the command is even the same:

dnf OPTION COMMAND PACKAGE

Like apt, there are a number of available options and commands. You will, as a beginner, most often use the dnf tool without options. The three commands you'll want to know as you begin using dnf are:

  • install - This installs a package
  • upgrade - This will update each package to the latest version (that is both available and resolvable)
  • remove - This will remove a package

So to install Thunderbird on a Fedora system, the command would be:

sudo dnf install thunderbird

To upgrade Thunderbird, the command would be:

sudo dnf upgrade thunderbird

To remove Thunderbird, the command would be:

sudo dnf remove thunderbird

Simple.

zypper

The zypper system is found on both SUSE and openSUSE. Zypper usage is very similar to that of apt-get and dnf. The command structure is:

zypper COMMAND OPTION PACKAGE

Notice the COMMAND and OPTION are reversed here. Since we're covering only the basics, this will not come into play. The three commands you will want to know first are:

  • install - Install a package
  • remove - Remove a package
  • upgrade - Upgrade a package

To install Thunderbird with zypper, the command would be:

sudo zypper install thunderbird

To upgrade Thunderbird with zypper, the command would be:

sudo zypper upgrade thunderbird

To remove Thunderbird with zypper, the command would be:

sudo zypper remove thunderbird

Zypper also has a bit of shorthand you can use for the above:

sudo zypper in thunderbird
​sudo zypper up thunderbird
​sudo zypper rm thunderbird

Go advanced

What we have done here is cover the basics. With the above information you can now install, upgrade, and remove software with apt-get, dnf, and zypper. You will, of course, want to learn more about these systems. Your first best bet is to read the man pages for each: man apt-get, man dnf, and man zypper. Within those pages you'll learn about all of the options and commands available.

Also see

About Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.

Editor's Picks

Free Newsletters, In your Inbox