If you are using the modern Linux distributions then you can find the software organized within packages that come with application binaries, files, metadata and other related information. Not only this, but you will also get the package dependencies, possible conflicts that may occur due to the presence of another package, and more. RHEL comes with a core package manager called rpm and is used by the DNF which is another higher level of package manager that helps in managing the dependencies of the packages. You can use the latest technology, flatpak, that helps in installing the sandboxed applications along with their runtime.
This article will highlight the following-
- Using three different ways for installing a package using rpm.
- installing packages using DNF
- installing applications graphically using a gnome-software utility
- Installing sandboxed applications using flatpak
Software requirements and other prerequisites
Requirements, Conventions or Software Version Used
You will be requiring the RHEL 8 / CentOS 8
All the used utilities in this guide are already installed, so no need to install them explicitly.
Appropriate permission for running the commands with the right root privileges.
What is a package?
CentOS 8 is one of the commonly used modern Linux distributions where the software is arranged in repositories in packages form. But what is a package? A package is considered to be a compressed archive that stores all the required files that are related to that software present in the package. It also contains the information that decides where and how these files need to be installed on the system. CentOS uses the rpm package format.
In this article, you can follow easy steps for installing and managing the rpm packages.
What is RPM (RedHat package manager)?
For managing the rpm packages, you can use the rpm package manager. Despite having powerful features, it does not resolve dependencies and only focuses on single packages. In order to manage the relationships between various packages along with avoiding the infamous dependency hell, you can go for yum package manager (Yellow Updater Modified). Later, it evolved as dandified yum (dnf). At the very first time, dnf was used in Fedora 18 and replaced yum in the last RHEL version.
How to install packages with rpm
With rpm, you can efficiently install the packages. But it is only applicable for the packages that do not have external dependencies as rpm cannot manage those dependencies. We have mentioned three different ways for installing packages using the rpm with different parameters (-i, -U, and -F) options.
- For installing a new package you can run rpm along with the -i (install)option with the below syntax.
$ sudo rpm -i packagename.rpm
You can run the above command for installing the specified package. But if you try to install an existing package, then you will get the following error.
$ sudo rpm -i gedit-3.28.1-3.el8.x86_64.rpm package gedit-2:3.28.1-3.el8.x86_64 is already installed
If you are upto the installation of the new kernel then this is the recommended method for installing the above same package with the exact version. In this case, the new and the old kernel will reside together. So if there is any failure, you can use them as a fallback.
- You will feel the difference in the usage of the (-U or upgrade) option. If you are looking for a package installation that does not exist then it will be installed. But if you are trying to install an existing package, it will get upgraded. After installing the new package it will automatically remove the older one. Before removing the older one make sure that the kernel will work without failing.
- When using -f or freshen option, you will see something different. Using this, the already existing packages will get updated. But it does not install the already installed packages.
How can you install a package from a remote location?
With rpm, you will be able to install a specific package that is not on the local filesystem. If you want to install a package that you can access via the ftp protocol, you can use the following command.
$ sudo rpm -i ftp://ftp.someaddress.com/package.rpm
Also, you can provide the username and password for authentication and can run the below command accordingly.
$ sudo rpm -i ftp://username:firstname.lastname@example.org/package.rpm
How to install a package with dnf
As we have mentioned already, dnf is the top package manager of rpm. Unlike rpm, it helps in managing the software dependencies along with installing the software from the distribution repositories. The metadata that comes with the rpm package helps in specifying what other packages need to be installed for that software to work properly and what package can create conflict.
But dnf helps in performing the required operations once it receives the confirmation from the user. For example, here we are installing the vim package via DNF by running the below command.
$ sudo dnf install vim
Once you run the command, you will get a list of all the operations to be performed and the list of dependencies to be installed.
================================================================================ Package Arch Version Repository Size ================================================================================
Installing: vim-enhanced x86_64 2:8.0.1763-7.el8 rhel-8-for-x86_64-appstream-beta-rpms 1.4 M
Installing dependencies: gpm-libs x86_64 1.20.7-15.el8 rhel-8-for-x86_64-appstream-beta-rpms 39 k vim-filesystem
noarch 2:8.0.1763-7.el8 rhel-8-for-x86_64-appstream-beta-rpms 47 k vim-common x86_64 2:8.0.1763-7.el8
rhel-8-for-x86_64-appstream-beta-rpms 6.3 M Transaction
Install 4 Packages Total download size: 7.8 M Installed size: 30 M Is this ok [y/N]:
If you want to run the DNF from within a script, you can use the -y option (assumeyes) that will provide the answer yes to all questions automatically. Like rpm, DNF also allows installing a package from a remote location using the below command.
$ sudo dnf install http://path/to/package.rpm
How to install a package graphically
If you are using the GNOME desktop environment, then you will be able to install a package graphically using the gnome-software application. If you want to install a package that is already present in the distribution repositories then you can search for it from there.
After that, you can click the install option for installing the application you want. The gnome-software application is a frontend for the packagekit which works as a high-level frontend. It helps in uniforming the installations on various distributions. If you use this method, the installed package will not get into the dnf history.
How to install software with flatpacks
If you are using CentOS 8, then there is another way of installing packages and that is flatpacks. It offers a sandboxed environment that contains the software with all its required dependencies. With this, we will be able to run a specific program version on every distribution supporting this technology irrespective of the native libraries.
The flatpack comes with a repository called flathub. Installing the flatpack with gnome software is an easy task. You need to look for the application for installing and click the install option. Gnome software will be launched automatically. If it does not start, then you can download the file with it. Then click the install option along with the right password for installation.
Once you install, the flatpak’s repository named -flathub will be added automatically as a flatpak source and helps the users for searching for the applications within it directly from the gnome-software centre interface. If you want to use the flatpak utility then you will be able to decide if you want to install it globally or just for a specific user. For adding the flathub repository globally, you can run the following command.
$ sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
Now you can start installing the package. For this, you need to provide the full package path along with the name of the remote repository that you want to install from. For example to install neovim, run the following
$ sudo flatpak install flathub io.neovim.nvim Required runtime for io.neovim.nvim/x86_64/stable (runtime/org.freedesktop.Sdk/x86_64/18.08) found in remote flathub Do you want to install it? [y/n]:
If we answer yes then the runtime will be downloaded and installed in our system.
Using this guide, you will be able to understand what package and package manager is. Also, you will get to know different package managers for CentOS 8. You can use package managers for installing packages that contain software along with complete dependencies so they can run independently anywhere.
You can run mentioned commands for installing packages using the different package managers.
People Are Also Reading:
I'm fascinated by the IT world and how the 1's and 0's work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited 'master chef'.