YUM is the default package management system for CentOS/RHEL and part of its role is to automatically calculate what packages may require updating, what dependencies are required, and to manage the entire process of updating your system in a very simple way.
The main configuration file of YUM is /etc/yum.conf, and the main directory, which stores the repository configuration file, is /etc/yum.repos.d/. The repository configuration file has got a specific syntax, and it should end with a .repo extension in the /etc/yum.repos.d/ directory.
The repository configuration file contains the URL of the repository, the repo id, repo name, instructions to use GPG for checking package signatures, and an option to enable or disable the repository.
If you encounter the below error:
yum: command not found
you may try installing the yum package as per your choice of distribution.
Distribution | Command |
---|---|
Debian | apt-get install yum |
Ubuntu | apt-get install yum |
Kali Linux | apt-get install yum |
CentOS | yum install yum |
Fedora | dnf install yum |
Raspbian | apt-get install yum |
yum Command Examples
1. To search for a single package, replace the keyword value with the appropriate phrase, string, or parameter, and type the following:
# yum search [keyword]
2. To install a single package, replace the package_name value with the appropriate value and type the following:
# yum install [package_name]
3. There are times when you may wish to install more than one package at a time. To do this, simply invoke the same install command, but instead of naming a single package, simply identify the full list of packages you may require in such a way that it forms a long shopping list.
# yum install [package_name1] [package_name2] [package_name3] ...
4. Install a new package and assume yes to all questions (also works with update, great for automated updates):
# yum -y install package
5. To remove a single package, replace the package_name value with the appropriate value and type the following:
# yum remove [package_name]
6. You can also use the yum command to clean any cached package information. To do this, log in as root and type the following:
# yum clean packages
7. Find the package that provides a particular command:
# yum provides [command]
8. To remove any cached XML-based metadata:
# yum clean metadata
9. To remove any cached database files:
# yum clean dbcache
10. To clean all the files:
# yum clean all
11. To rebuild the YUM cache:
# yum makecache
12. The below command will allow YUM to continue working by bypassing any packages with errors, but this should be regarded as a temporary fix only.
# yum -y update --skip-broken