Don’t let Windows or Mac users scare you that adding or removing software on a Linux computer is only for bravehearts.
Installing, upgrading or removing software on Linux systems is no longer the daunting chore it used to be some years back.
Broadly speaking, there are two ways to install software packages on a Linux system.
You can install software packages either through a graphical user interface (GUI) or do it via the command line.
Major desktop Linux distros like Fedora Workstation 21, Linux Mint and Ubuntu now have slick GUIs that make searching for and installing new software a breeze.
The big advantage with GUI based installers is that they take care of dependency resolution so newbies won’t have to fret whether the package they’re installing or upgrading will work without having to install other software.
But you can be sure that hardcore Linux enthusiasts and system administrators will always opt for the command line to install, upgrade or remove software.
In large business environments (such as a web hosting companies) where headless servers are often the norm, Linux system administrators work exclusively on the command line.
Command Line Installation
On the command line, two kinds of tools (low level and high level) are available to install software packages on a Linux system.
The first method (dpkg for Debian and rpm for Red Hat) does not resolve dependencies and are therefore considered low level tools.
The high level installation tools (apt-get or yum) take care of dependencies.
In case you didn’t know, dependencies are other software that an application requires before it can work.
dpkg and rpm are low-level tools while apt-get and yum are considered high-level tools because they take care of dependencies as part of the installation process.
In this post, we’ll look at installing and removing software packages on both Debian based distributions and Red Hat style distros (like Fedora, CentOS and OpenSUSE that follow the Red Hat methodology) via the command line.
As you no doubt guessed, the commands for Debian and Red hat are completely different.
So we’ll have to consider them separately to avoid confusion.
We’ll consider Debian and its derivative distros first.
Installation on Debian
Commands mentioned in this section should work on Debian, Ubuntu, Linux Mint, Xandros and more.
Install a Package
Linux users opt for dpkg with software that are not downloaded from a repository.
Here’s how you install a package with dpkg.
# dpkg -i package_name
When you install a .deb package via the low-level dpkg tool, be aware that there is no dependency resolution.
So if the package you’re installing requires other software you’re stuck.
To avoid dependency issues, you must use higher-level tools like apt-get to install software on Debian and its derivatives. Strictly speaking, this is not always possible because not all packages are in repositories.
When you use the high level apt-get install tool, you’re downloading software from a repository.
The first step is to run update and then search for the package you’re interested in.
# apt-get update
# apt-cache search search_string
If you’re looking for an RSS reader, you’d run the below command first.
# apt-cache search rss
That’s how I discovered RSS readers like Quiterss and Liferea.
Finally, when you’ve found the package you want just install it with the following command.
You can skip the search step if you already know the package you want to install.
# apt-get install package_name
List Packages Installed
Your Ubuntu or Linux Mint computer has dozens of packages installed on it.
If you want the entire lengthy list, go with the following command.
$ dpkg -l
I recommend you save the output to a text file for leisurely analysis later.
$ dpkg -l > MyPackageList.txt
Total Packages Installed
Say you want to find out how many packages are installed on a Linux system without the long list of all the individual packages.
You use the dpkg with the -l option and then pipe it to wc -l.
On my Ubuntu system, I was curious about the total packages installed.
Here’s what I did:
$ dpkg -l | wc -l 2215
Remove a Package
Removing a package on a Debian, Ubuntu or Linux Mint computer is no sweat with the below command.
# dpkg -r package_name
Alternatively, if it’s a package downloaded from a repository you should go with either of the following commands.
# apt-cache remove package_name
But the above command leaves behind configuration files.
If your goal is to remove the configuration files too, you must use the purge option.
apt-cache purge package_name
Information About a Specific Package
If you’re looking for more information on a specific package, what command would you run?
In the below example, I sought information on the popular Cherrytree notes application.
$ dpkg -l cherrytree | tail -1 | tr -s ' ' ii cherrytree 0.35.7-1~ppa1~trusty1 all hierarchical note taking application
Verify if Package is Installed
You can check if a particular software package is installed on your Debian or Ubuntu computer.
Say you want to see if an rss package is installed on your Ubuntu computer.
Here’s the command you ought to run:
$ dpkg -l | grep rss ii quiterss 0.17.6-0ubuntu1~trusty amd64 RSS/Atom feed reader written on Qt
If quiterss weren’t installed on my Ubuntu PC, I wouldn’t have got any response.
Red Hat & Red Hat Syle Distros
Let’s now take a dekko at how to install software on Red Hat and its derivative distributions like CentOS and Fedora.
Red Hat is the favorite Linux distro for scores of large corporations around the world.
Familiarity with installing, upgrading and removing software on Red Hat systems is definitely a huge plus on your resume.
Installation on Red Hat
If you’ve downloaded a package from a non-repository, you’d run rpm -i to install it.
# rpm -i package_file
Remember that rpm -i is a low level installation tool. So if a dependency issue crops up during installation, you’re stuck.
Where available in repositories, it’s better to use the high-level installation tool yum that takes care of dependencies.
# yum install package_name
If you’re unsure which package you want to install for a particular task, you can always run a search.
# yum search search_string
So if you’re looking for a RSS reader but don’t know the name, run a search.
# yum search rss
You’d be surprised at the various choices you get in the output – Included are Quiterss, Liferea, Evolution RSS reader and more.
Upgrading a Package on Red Hat
If you’re using the low level tool rpm, the upgrade command for a package goes like this:
# rpm -U package_file
But if you’re upgrading a package that you downloaded from a repository, use the below command.
# yum update package_name
If you run yum update without specifying a package name, the command will update all currently installed packages.
During the updating process, yum will ensure that all dependencies are satisfied.
Make it a point to frequently check if any of the installed packages have updates available with the following command:
# yum check-update
You can also use update packages by running yum upgrade package_name. When you use upgrade, it’ll remove obsolete packages something that update does not do.
Linux experts recommend using update package_name for the day to day stuff, and choosing upgrade package_name if you’re doing a full system upgrade to a new version of the distribution.
List All Installed Software
What command would you use to list all software installed on a Red Hat system?
Now that’s easy!
You’d get a lengthy response in your output.
So I suggest redirecting the output to a text file that you can glance at leisurely later.
$ rpm-qa > My-RedHat-Packages.txt
Total Packages Installed
$ yum list | wc -l 45365
Verify Package Installion
It’s easy to check if a particular package is installed on your Red Hat or CentOS computer.
Say you want to see if rsync is installed and its version.
Just run the below command.
$ rpm -qa | grep rsync rsync-3.1.1-3.fc21.x86 64
Remove a Package
Removing a package on a Red Hat server or Fedora desktop is simple as pie with the following command.
# rpm -e package_name
Alternatively, if it’s a package downloaded from a repository you should go with the following command.
# yum remove package_name
Info on Installed Package
Picture a situation where you know that a tool is installed on the Red Hat or CentOS computer and you’d like information about its version and other details.
In such a scenario, you’d use the yum info package_name command.
Let’s run yum info below with rsync as our example.
$ yum info rsync Loaded plugins: langpacks Installed Packages Name : rsync Arch : x86_64 Version : 3.1.1 Release : 3.fc21 Size : 816 k Repo : installed From repo : koji-override-0 Summary : A program for synchronizing files over a network .....
Whether you’re running Debian or a Red Hat derivative on your computer, this post should serve as a solid primer on how to search for, install, update and remove packages.
Once you get to speed with this primer, look up the man commands for apt-get/yum and dpkg/rpm.
Sorry, the comment form is closed at this time.