The yum command improves the functionality of rpm while still using .rpm packages and maintaining an RPM database. It provides a more straightforward method for managing packages. One of the biggest benefits of YUM is the ability to automatically handle software dependencies. This means that administrators can tell YUM to install a particular package, along with automatically installing any additional packages that the package depends on.

An additional YUM benefit is the use of repositories. Repositories are storage locations for .rpm files. Repositories enable administrators to more easily maintain version control over the software.

Syntax

The syntax of the yum command is:

# yum [options] [subcommand] [package name]

The -y Option

Use the -y option with the yum command to automatically answer yes to installing additional software dependencies. If you do not, YUM will prompt you to answer yes or no to whether the additional dependencies should be installed.

yum Subcommands

The yum command comes with several subcommands for managing packages.

Subcommand Used To
install {package name} Install the package from any configured repository.
localinstall {package name} Install package from local repository.
remove {package name} Uninstall the package.
update [package name] Update the package; if none provided, updates all installed packages (time-consuming).
info {package name} Report information about the package.
provides {file name} Report what package provides the specified files or libraries.

yum Command Examples

1. To Install

a. To install any package on the Linux system, we can fire the yum install and the package name:

# yum install package1.rpm
# yum install package1.rpm package2.rpm package3.rpm package4.rpm

b. Yum utility generally ask for the confirmation for package installation, if you want to specify it in the command itself then fire below command

# yum install package1.rpm -y

2. To Search

To search for any package on the RPM repository (it can be RHN, Cent OS repository etc.):

# yum search package1.rpm
# yum search package1 package2
# yum search all

3. To Update

To update any existing package on the system fire below update command:

# yum update package1.rpm
# yum update package1.rpm package2.rpm
# yum update package1.rpm -y

4. To remove/uninstall

To remove any existing package from the system:

# yum remove package1.rpm
# yum remove package1.rpm package2.rpm
# yum remove package1.rpm -y

5. To update

To update the entire system for the available updates from Vendor repository:

# yum check-update
# yum update
# yum update –y        
# yum update yum

6. Get info

To get the information about any package:

# yum info yum
# yum info vsftpd

7. To see the lists

To list packages we can fire below commands:

# yum list all
# yum list available
# yum list installed
# yum list extras
# yum list updates
# yum list obsoletes
# yum list recent
# yum list | less
# yum list pkgspec

8. To clean

To clean the downloaded packages or metadata or information cached by yum utility:

# yum clean package1.rpm
# yum clean metadata
# yum clean expire-cache
# yum clean rpmdb
# yum clean plugins
# yum clean all

9. To see what provides

To see what service/file is provided by which package:

# yum provides vsftpd
# yum provides yum
# yum whatprovides vsftpd
# yum whatprovides /etc/passwd

10. For groups

The packages are grouped into Group List, like DNS, Desktop, Web Server etc. So to view/install/update the packages from grouplist fire below command.

# yum grouplist
# yum groupinstall "DNS Name Server"
# yum groupinstall "DNS Name Server" "Graphical Internet"
# yum groupupdate "DNS Name Server"
# yum groupremove "DNS Name Server"
# yum groupremove "DNS Name Server" "Graphical Internet"

11. Get info about group

To get the information about the package groups:

# yum groupinfo "Graphical Internet"
# yum groupinfo "Graphical Internet" "DNS Name Server"

12. Resolvedep

To specify to resolve the dependencies if any while installing or update the packages:

13. To download only

To just download the packages on the system we can fire below commands:

# yum install yum-downloadonly
# yum install vsftpd --downloadonly
# yum update vsftpd --downloadonly
# yum update --downloadonly --downloaddir=/tmp

14. To locally install

To install the downloaded packages from any local directory:

# yum localinstall package1.rpm 
# yum localinstall package1.rpm package2.rpm
# yum localupdate package1.rpm
# yum localupdate package1.rpm package2.rpm

15. Reinstall

To re-install any package, i.e. to unistall and then install it again:

16. Downgrade

To downgrade any package to the previous version:

# yum downgrade vsftpd
# yum downgrade vsftpd bash

17. To see dependency list

To see any dependencies for the specified package:

# yum deplist vsftpd
# yum deplist vsftpd bash

18. Version

To see the version information about any package:

# yum version all
# yum version installed
# yum version available
# yum version group
# yum version grouplist

19. History

This allows the user to view what has happened in past transactions:

# yum history
# yum history info
# yum history list
# yum history summary
# yum history redo
# yum history undo
# yum history new