Yum (Yellowdog Updater, Modified) is at the core of the CentOS, Red Hat and Fedora package management systems.
On Linux distros like CentOS 7, RedHat 7 or Fedora 21, if you want to update, install or remove packages, list installed packages or update the entire system while at the same time ensuring automatic dependency resolution then the command line tool you must deploy is yum.
Yum also comes in handy while enabling or disabling repositories (package sources).
To update, install or remove packages via yum, you must have superuser privileges (via su or sudo).
Now let’s take a look at some of the key Yum commands you ought to be familiar for CentOS 7.
1. Check for Updates
$ yum check-update
The above command only checks for and lists available updates but it will not install them.
There’s no need to be logged in as a superuser to check for available updates.
2. Update a Single Package
More often not, you’ll be required to update only a single package, not all the packages.
Use the below command if you wish to update just a single package and you know its name.
$ yum update package_name
3. Update All Packages
If you intend to update all packages along with their dependencies, go with either of the below commands.
$ yum update
$ yum upgrade
I usually go with yum update if I’m updating multiple packages.
4. Search Packages
You can check enabled repositories for packages you wish to install on your CentOS 7 or RedHat 7 system.
There’s no need to know the name of the package during the search.
Let’s say you heard about a good RSS package but forgot its name. So just use rss in the search string.
$ yum search search_string
Search Multiple Packages
Yum lets you search for multiple packages simultaneously.
In the below example, I’m searching for the Cherrytree notes app and the Quiterss RSS reader.
$ yum search cherrytree quiterss
If you want to do a thorough search of the enabled repositories, use the below command. But be warned that the process will be slower.
$ yum search all cherrytree
5. Install a Single Package
As a system administrator, you should know how to install a new package along with its dependencies.
$ yum install package_name
Install Multiple Packages
$ yum install package1_name package2_name package3_name
6. Local Install
You can also use yum to install a previously downloaded package from a local directory.
$ yum localinstall path
7. List Installed Packages
To get a complete list of all packages installed on your CentOS 7 or RedHat 7 system, run the below command.
$ yum list installed
The above command is similar to rpm-qa in its output.
8. Removing a Package
Uninstalling a package is easy as pie with yum.
$ yum remove package_name
So if you want to uninstall the quiterss RSS reader, you’d issue the following command
$ yum remove quiterss
Both install and remove can take the following arguments:
9. Enabled Repositories
A repository is the source for packages.
Your Linux server or desktop might be configured for one or more repositories. When you download a package, it usually comes from a repository (unless you take the risky step of downloading it from elsewhere).
To check the list of repositories enabled on your system, run the following command:
$ yum repolist
Enabled Repositories with Details
$ yum repolist -v
$ yum repoinfo
Display All Repositories (Enabled & Disabled)
If you wish to see the list of both enabled and disabled repositories, go with the following command:
$ yum repolist all
10. Display Package Information
Yum is also a good tool to get a good bit of information on a package.
$ yum info package_name
Let’s say that you’re looking for more information on a RSS package called quiterss that’s installed on your system.
$ yum info quiterss
In this post, we have only skimmed the surface of yum.
There’s a lot more you can do with yum like group install, group update or group remove packages and download special plugins to extend yum’s capabilities. Take a dekko at the man pages for yum.