In this tutorial, we show you how to install or remove software packages in CentOS Stream 8 and how to find out in which repository the software can be found.
Follow the steps in this article from command-line as root user, or with sudo.
Installing a package
In CentOS Stream 8, you install packages with the command:
dnf -y install packagename
DNF is a meta package handler with which you can manage packages, for example, or create repositories. It is similar to Yum which was originally used in CentOS and is still present in CentOS Stream 8 installations by default.
By adding -y, you automatically give permission when you are asked for permission to install the relevant package.
Finding out in which package software is included
Do you want to use a command, but do you see a message saying that the command cannot be found? Then you can find out if you can install it by checking if it is part of a package that is included in a repository which you use in CentOS Stream 8. You do this with the command:
dnf whatprovides */nameofcommand
If you want to use netstat, for example, you use the command:
dnf whatprovides */netstat
In addition to repository and/or meta data information, the output will include a section similar to this:
Loaded net-tools-2.0-0.52.20160912git.el8.x86_64 : Basic networking tools Repo : baseos Matched from: Filename : /usr/bin/netstat
The first line shows is the package you need, in this case net-tools. Therefore, to use the netstat command, you install net-tools:
dnf -y install net-tools
Finding out in which repository software is included
It may happen that the software you want to install is not included in a repo that you are currently using. In that case, the relevant software cannot be installed. This applies, for example, to a default installation of CentOS when you try to install Fail2Ban, which is part of the EPEL repository.
You can determine whether this is the case by seeing if the software is part of a package included in your current repositories. You use one of the commands for this:
dnf whatprovides */nameofcommand
If you get the message 'No matches found', or you do not see any results with the line Filename: /bin/softwarename, then this means that the required package does not exist, or is part of another repository.
In Linux, the idea is that, for security reasons, you can only search and install software in your own sphere of influence, but not outside of it. So, you have access to repositories that you have installed, but you cannot perform a search in uninstalled repositories. The only option to find out in which repository a package is included if you have not yet installed the repository is to look it up via a search engine such as Google / DuckDuckGo, or, for example, on Gitlab.
Updating installed software packages
You can easily update all installed software in CentOS Stream 8 with the command:
dnf -y update
It's always safest to afterwards reboot your VPS to ensure updates that require a reboot are processed and you won't run into potential surprises at a later date.
Removing installed software packages
Software packages are removed using a single command:
dnf -y remove nameofpackage
Should you have forgotten the package name, you can first look up the package name again using the command:
dnf whatprovides */nameofcommand