[Linux]: 15 most frequently used YUM Commands with examples

Updated on September 3, 2017

YUM stands for Yellowdog Updater Modified, is an open source command line package management for RPM-based distributions of Linux like RedHat, CentOS, Fedora etc. YUM allows system administrators to easily Install, Update, Search or Uninstall software packages on a system.

System admnistrators can configure YUM to use third party repositories to install packages automatically by resolving their dependency issues. Here we would see those 15 most frequently used YUM commands with examples.

Yum Package Manager
Yum Package Manager

1. How to Install a package using YUM

If you are a newbie to Linux administration and if would have installed any software using rpm installation, then you would know the pain of   installing all dependencies before you could install the original one. But Linux  gives you that power which other OS wouldn’t give ie.,  YUM which will automatically find and install all required dependencies for the software. To install a package, do ‘yum install packagename’. Ex: yum install

[root@catest ~]# yum install firefox

You would have noticed during the above command execution, that it would prompt you to accept or decline Is this ok [y/N]: . If you want YUM to install automatically without prompting, use -y option as shown below :

[root@catest ~]# yum -y install firefox

Sometimes you may need to install all corresponding developmental packages/libraries/test packages etc., along with the main package. In that case you can use * sign for installing all the packages which starts with mysql instead of specifying each package for installation.

[root@catest ~]# yum -y install mysql*

This would install packages like mysql-bench, mysql-connector-odbc, mysql-devel, mysql-server, mysql-test etc.,

2. How to get a package information using YUM

Sometimes you would like to know information about a package already installed on your system before any further upgradation ! Just follow the below command to know more information of a package.

[root@catest ~]# yum info firefox
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
Installed Packages
Name       : firefox
Arch       : i386
Version    : 17.0.8
Release    : 1.el5.centos
Size       : 29 M
Repo       : installed
Summary    : Mozilla Firefox Web browser.
URL        : http://www.mozilla.org/projects/firefox/
License    : MPLv1.1 or GPLv2+ or LGPLv2+
Description: Mozilla Firefox is an open-source web browser, designed for standards
           : compliance, performance and portability.

Name       : firefox
Arch       : x86_64
Version    : 17.0.8
Release    : 1.el5.centos
Size       : 29 M
Repo       : installed
Summary    : Mozilla Firefox Web browser.
URL        : http://www.mozilla.org/projects/firefox/
License    : MPLv1.1 or GPLv2+ or LGPLv2+
Description: Mozilla Firefox is an open-source web browser, designed for standards
           : compliance, performance and portability.

3. How to upgrade/update a software using YUM

You need to keep updating your firefox as and when firefox releases new version. To do this just run the following command and it will automatically update your firefox.

[root@catest ~]# yum update mysql

4. How to remove/Uninstall a software package using YUM

Uninstallation of packages along with all its dependencies, use ‘yum remove package’ as shown below.

[root@catest ~]# yum remove mysql

5. How to search for a software package using YUM

When an exact package name to be installed is not known, then use ‘yum search keyword’. This will search all the packages which matches with the “keyword” and display it.

[root@catest ~]# yum search firefox
Wed Nov 06>$yum search firefox
Loaded plugins: security
============= Matched: firefox ==================
firefox.i386 : Mozilla Firefox Web browser
firefox.x86_64 : Mozilla Firefox Web browser
rubygem-less.noarch : Dynamic stylesheet support for Ruby
xulrunner.i386 : XUL Runtime for Gecko Applications
xulrunner.x86_64 : XUL Runtime for Gecko Applications
Wed Nov 06>$

6. How to list all the packages available in the YUM database

The following command will list all of the packages available in the YUM database.

[root@catest ~]# yum list | less

7. How to list all the installed packages on your system.

The following command will list all the installed packages on your system.

[root@catest ~]# yum list installed | less

8. How to find out which are the packages available for upgradation using YUM.

If you want to find out whether specific package is up-to-date you can use point 2. But as a whole system if you would like to find out which are all the packages ready for upgradation, run the below command :

[root@catest ~]# yum list updates | less

9. How to find a file belonging to which package using YUM.

If you would like to know the file /etc/sysconfig/nfs belongs to which packages, then just run the below command and see the output as it belongs to nfs-utils-1.0.9-70.el5.x86_64.

[root@catest ~]# yum provides /etc/sysconfig/nfs
Loaded plugins: security
1:nfs-utils-1.0.9-70.el5.x86_64 : NFS utilities and supporting clients and
                                : daemons for the kernel NFS server.
Repo        : centos
Matched from:
Filename    : /etc/sysconfig/nfs

1:nfs-utils-1.0.9-44.el5.x86_64 : NFS utilities and supporting clients and
                                : daemons for the kernel NFS server.
Repo        : installed
Matched from:
Other       : Provides-match: /etc/sysconfig/nfs

10. How to cleanup YUM cache

When you install any package using YUM, it downloads the packages(RPM files) to your local YUM cache directory located at /var/cache/yum/. Particularly the packages RPM that have been downloaded can occupy much space and is of no reason to leave it when its job is done. In order to make the corresponding cleaning, the following command can be executed to clean up all at once :

[root@catest ~]# yum clean all

11. Search the list with specific package name

To search for package names only, use yum list. This differs from normal search which is much faster, as it will search package names only, while yum search will search all the package info, including package description.

[root@catest ~]# yum list firefox
Loaded plugins: security
Installed Packages
firefox.i386                     3.0.18-1.el5_4                        installed
firefox.x86_64                   3.0.18-1.el5_4                        installed
Available Packages
firefox.i386                     17.0.8-1.el5.centos                   centos
firefox.x86_64                   17.0.8-1.el5.centos                   centos
Wed Nov 06>

12. Know your YUM repositories configured

To know the repositories that are configured in your system, do ‘yum repolist’ as shown below.

[root@catest ~]# yum repolist
Loaded plugins: security
repo id             repo name                                              status
centos              CentOS 5Server - x86_64                              enabled:  3662
rpmforge            RHEL 5Server - RPMforge.net - dag                    enabled: 11318
repolist: 14980
Wed Nov 06>$

To display all the repositories (ie., configured and not configured on your server) run the below command:

[root@catest ~]# yum repolist all
Loaded plugins: security
repo id             repo name                                                   status
centos              CentOS 5Server - x86_64                                  enabled:  3662
rhel-debuginfo      Red Hat Enterprise Linux 5Server - x86_64 - D            disabled
rhel-debuginfo-beta Red Hat Enterprise Linux 5Server Beta - x86_6            disabled
rpmforge            RHEL 5Server - RPMforge.net - dag                        enabled: 11318
rpmforge-extras     RHEL 5Server - RPMforge.net - extras                     disabled
rpmforge-testing    RHEL 5Server - RPMforge.net - testing                    disabled
repolist: 14980
Wed Nov 06>$

13. How to install a package from a non configured repository using yum –enablerepo

By default yum installs only from the enabled repositories. For some reason if you like to install a package from a disabled repositories, use –enablerepo option in the ‘yum install’ as shown below.

[root@catest ~]#yum --enablerepo=rhel-debuginfo install vim-X11.x86_64

14. To list recent updated/added packages to the repository database using YUM

To get a list of packages updated/added to any of your repositories recently:

[root@catest ~]# yum list recent

15. YUM interactive shell

You can run multiple commands on the interactive shell provided by YUM as shown below :

Wed Nov 06>$yum shell
Loaded plugins: security
Setting up Yum Shell
> info mysql

I hope this will help you understand how to use yum more effeciently.

Was this article helpful?

Related Articles

Leave a Comment