Package management

Package managers are tools that automate the process of finding, downloading, installing and updating software from trusted repositories. Different Linux distros use different package managers; Debian-based use apt, RHEL-based used yum or dnf, OpenSUSE-based used zypper, and Arch-based use pacman.1

Package management in Debian-based systems revolve around dpkg and apt. The former is a lower-level tool used to install .deb packages manually: for example, sudo dpkg -i <package>.deb is the command to install a specific package, while the -r flag is used to remove them.

Note that dpkg does not automatically handle dependencies. Additionally, rpm is also compatible with Debian systems, although not native.

RHEL systems use yum or dnf (which is the newer replacement for yum). Basic commands are:

  • sudo dnf install
  • sudo dnf remove
  • sudo group install <Group Name> - used to install a full set of related software at once.
  • sudo dnf upgrade
  • sudo dnf check-update

The OpenSUSE zypper has very similar syntax to dnf. Note that to update repositories we use zypper refresh.

Manual installations

We can use manual installations when a specific package is not available in a repository, or when we require to custom build of the program. The general process for manual installations is:

  1. Download source code
  2. Extract
  3. Configure build environment
  4. Compile source files
  5. Install files

The general pattern for this includes going to whatever configuration directory there is, then using make to compile and then make install.

Repository management

In a Debian basedf system we can add GPG keys to a repository with the following command:

wget -qO - https://example.com/repo.key | sudo apt-key add --

To enable/disable a specific repository we can modify the /etc/apt/sources.list file. Other distribution package managers will likely have similar mechanisms. For instance, RHEL distros use dnf config-manager --set-<enabled/disabled> <repo-name>.

Package / repo exclusions

In Debian distributions we can use apt-mark hold to lock a specific package to a current version, thus preventing automatic updates when apt upgrade is used. To see the packages being held, use apt-mark showhold.

Alternatively, we can use dpkg --set-selections to manage selections and holds in bulk. It is used with echo "nginx hold" | sudo dkpg --set-selections.

In RHEL, dnf versionlock is used to freeze the version of a package: dnf versionlock add/delete <package-name>. In OpenSUSE, zypper al/ll/rl (add lock, list locks, remove lock) is used. To remove a repository, use zypper mr -d.

Update alternatives

When installing packages, there may be many versions of a specific package. We can use the following commands to manage alternatives:

  • update-alternatives --list
  • update-alternatives --config
  • update-alternatives --install

Footnotes

  1. Of course, there are alternatives. I use Arch, btw, and so I am familiar with paru and yay which themselves give you access to the Arch User Repositories.