On "Enterprise Linux" variants--CentOS, CloudLinux, AlmaLinux, and RockyLinux--you can utilize the 'yum' utility to manage RPM packages installed on the system. On EL8 and above, it is recommended to use 'dnf' rather than 'yum,' however, both will work.
Ubuntu based systems should review similar instructions for the APT package manager.
You can add, remove, and swap packages with the yum utility, as well as search and browse packages.
Installing a package
You can install a package using the command below where PACKAGE is the package name.
yum install PACKAGE
For example, if you want to install the PHP 7.4 Intl extension we just found.
yum install ea-php74-php-intl
Removing a package
You can remove a package with the command below, where PACKAGE is the package name.
yum remove PACKAGE
For example, removing the PHP 7.4 Intl extension we just installed.
yum remove ea-php74-php-intl
Note: Always review the packages that will be removed as the package you are attempting to remove may be a dependency of other packages. Removing needed packages could potentially result in irreparable damage to the server.
Updating a package
You can update a package with the command below, where PACKAGE is the package name.
yum update PACKAGE
For example, updating the sudo package.
yum update sudo
Updating all packages
You can update all packages by running the update command without any packages specified like so.
Replacing one package with another
If you're trying to replace a package with a different version, rather than remove and reinstall all of the packages that depend on it, you can swap the package:
yum swap -- install $NEW -- remove $OLD
or, if you need to handle multiple packages, you can enter the yum shell:
remove $OLD1 $OLD2 $OLD3
install $NEW1 $NEW2 $NEW3
update $UPDATE1 $UPDATE2