The yum command in Linux – A Complete Reference

Yum Command

YUM command (Yellowdog Updater Modified) is the traditional package manager for RedHat based systems. It is present in almost every RedHat based distro but isn’t the default in many of them now. It has been replaced by the newer DNF command. We have a separate article on DNF.

yum command Basic Usage

The general syntax of YUM command is

yum [options] <command> [<args>...]

Available commands include install, search, query, etc. args can be a package name, a group name, or subcommand(s) specific to the ‘command’.

Note: To install and remove packages, you need to have sudo privileges. Since I am already root( which is not a great idea but works for the purpose of demonstration), I won’t be prepending any command with sudo. But keep in your mind that you must prepend sudo while installing and removing packages.

Note: On modern systems(CentOS 8 specifically) /usr/bin/yum is just a symlink to dnf. So, running yum eventually runs dnf.
This doesn’t cause a problem as dnf has almost the same syntax as yum.

Managing packages using the yum command

Let’s now see how we can use the yum command to install/remove/query packages on our RedHat based system.

1. Search and Install packages

Let’s install Syncthing – the file-syncing application using the yum command. But you may not know the exact name of the package. It’s better to search for the package first. You can use the search command of YUM for searching packages.

yum search syncthing
Yum Install Syncthing
Yum Search Syncthing

In our case, the name of the package is also syncthing. Once you know the exact package name, you can use the install command of YUM for installing that package.

yum install syncthing
Yum Install Syncthing 1
YUM Install Syncthing

2. List information about a package

To list more information about a package, use the info command of YUM.

Yum Info
YUM Info Syncthing

3. List all installed packages using yum

To see the list of installed packages, you can use the list installed command of YUM.

yum list installed
Yum List Installed
YUM List Installed

Combined with the grep command, you can search whether a particular package is installed or not as follows

yum list installed | grep vim
Yum List Installed 1
YUM List Installed Vim

If it didn’t produce any output, it means that the package is not installed. In that case.


4. Remove a package

To remove a package, use the remove command of YUM.

yum remove syncthing
Yum Remove
YUM Remove

To remove all unneeded packages that were originally installed as dependencies, use the autoremove command

yum autoremove
Yum Autoremove
YUM Autoremove

5. Upgrade a package using the yum command

To upgrade all the packages that can be upgraded, use the upgrade command

yum upgrade
Yum Upgrade
YUM Upgrade

To upgrade a specific package, just add the name of the package, for example:

yum upgrade nftables
Yum Upgrade Nftables
YUM Upgrade Nftables

6. Search and Install package groups

Package groups are just multiple packages under a single name. These packages groups can be a whole server GUI, Security Tools, Administration Tools, etc. To see the list of groups, you can use the group list command of YUM.

yum group list
Yum Group
YUM Group List

To know which packages are there in a group package, just use the group info command and give the name of the package. For “Security Tools” package, type

yum group info "Security Tools"

Note: You need to enclose the Group Package Name which has multiple words in quotes(” “).
Even if the Group package name is a single word, it is recommended that you use quotes.

Yum Groupinfo
YUM Group Info

Let’s install the Security Tools Group package using the group install command.

yum group install "Security Tools"
Yum Group Install
YUM Group Install

7. List available or enabled repositories

To list all the available repositories, type

yum repolist all
Yum Repolist
YUM Repolist

To list all the enabled repositories, type

yum repolist enabled
Yum Repolist Enabled
YUM Repolist Enabled

8. List dependencies of a package

To list the dependencies of a package, use the deplist command.

yum deplist syncthing
Yum Deplist
YUM Deplist

9. View history of installation/removal of packages

Sometimes, viewing your YUM history is a good idea especially if you want to repeat the installations on a different system. History can be viewed using the history command of YUM.

Yum History
YUM History

Conclusion

This tutorial was about the yum command in Linux. Hope you had fun learning with us!