Question
How do you use yum to manage packages?
Answer
On "Enterprise Linux" variants, such as 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:
How to list and search available software packages on Ubuntu
You can add, remove, and swap packages with the yum utility, as well as search and browse packages.
Note: On EL8 and above-based systems, you can replace yum with dnf in the examples below.
You can install a package using the following command, where PACKAGE is the name of the package you wish to install:
# yum install PACKAGE
For example, if you want to install the PHP 7.4 intl package:
# yum install ea-php74-php-intl
You can remove a package with the following command, where PACKAGE is the name of the package you wish to remove:
# yum remove PACKAGE
For example, you can remove the PHP 7.4 intl package by running:
# 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.
You can update a package using the following command, where PACKAGE is the name of the package you wish to update:
# yum update PACKAGE
For example, to update the sudo package, you would run:
# yum update sudo
You can update all packages by running the following command:
# yum update
If you are 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
Note: You need to replace "$NEW" and "$OLD" with the packages you want to replace
Or, if you need to handle multiple packages, you can enter the yum shell:
# yum shell
install $NEW1 $NEW2 $NEW3
update $UPDATE1 $UPDATE2
run
Additional Resources
Searching for a package by name or description
Searching for a package by contents
Searching for historical install information about a package
Ensure packages from an old repository are updated with packages from a new repository
Comments
0 comments
Article is closed for comments.