Jun 28, 2018

15 min read

Linux package managers: Learning apt and yum

Written by

Vippy The VPS
If you are coming from the desktop side of computing, especially from Windows, then the notion of package management may seem a little odd to you. However, it is easy to understand the functionality and the advantages of using Linux package managers. On the server side of computing, or on Linux in genreal, your applications run on top of layers of other software. A simple blog built using Wordpress may depend on an Apache web server, PHP modules, and a MySQL database. These packages themselves depend on lower-level libraries. As these are independent projects, if there’s an update released for Apache web server, there’s no guarantee that, say, MySQL will work perfectly with the newer version. To make matters worse, even the base operating system is constantly evolving and receiving updates that might be crucial but can potentially break the applications running on top of it. To solve these, and many other complications, we are going to familiarize ourselves with package managers.

What are Package managers?

  • Package managers are responsible for making sure you don’t get drowned in a complex list of inter-dependent software that you require for your application to run. They perform the following tasks.
  • Keep a list of trusted remote repositories from where the packages can be downloaded and installed.
  • Maintain a local index of all the available and installed packages.
  • Keep track of what packages are needed as dependencies for a particular package.
  • Perform package installations including bringing in the dependencies, adding binaries to PATH and making system-wide changes.
  • Update packages when a newer version comes in the remote repository.
So let’s get started with the two package managers that you are most likely to cross paths with, namely apt and yum. Note: If you are planning on using Ubuntu or Debian, follow the apt package manager section. On the other hand, if you use CentOS you can skip ahead to yum package manager instead. [cta_inline]

APT package manager

Advanced Packaging Tool (or APT) is the defacto package manager for many variants of Debian and Ubuntu operating systems. It installs packages system-wide and therefore requires root privileges to carry out the task. That’s why most commands below begin with sudo. If you are already logged in as the root user, you may skip the sudo part of the command.

Install a package

To install a package named PACKAGE_NAME, all you need to do is run:
$ sudo apt-get install PACKAGE_NAME
Or you can use a shorter command:
$ sudo apt install PACKAGE_NAME
What happens here is that the apt-get utility consults a local index of package names sees a match for PACKAGE_NAME and gets the package and necessary dependencies for it from a list of trusted URLs. It then installs the package and its dependencies and makes a note about these newer additions that are made to the system. The command may nag you to confirm that you want to install the package, by entering y or yes if you want to avoid that, use the -y flag.
$ sudo apt-get install -y PACKAGE_NAME
You can also use the -qq flag which updates the system without printing anything to the terminal. This is useful when you are writing shell scripts to automate any apt related task.

Install packages from your filesystem

Debian and Ubuntu packages typically come as files with .deb extension. If you have one of these in your local filesystem you can install it by first traversing to the directory where the file is located and then running:
$ sudo dpkg -i FILENAME
dpkg is the utility that is responsible for the actual installation and configuration in the backend. apt interfaces with it every time it needs
Continue reading this article
by subscribing to our newsletter.
Subscribe now

A note about tutorials: We encourage our users to try out tutorials, but they aren't fully supported by our team—we can't always provide support when things go wrong. Be sure to check which OS and version it was tested with before you proceed.

If you want a fully managed experience, with dedicated support for any application you might want to run, contact us for more information.

Leave a Reply