YUM or Yellowdog Updater Modified is a utility for managing of rpm packages & is available for all Redhat OS & other Linux distros based on Redhat. It is used to install, remove, update & to gather information about rpm packages through command line interface or by using graphical mode.

While using RPM for installing packages, we are required to install all the dependencies before we can install the package but YUM automatically resolves & installs dependencies without us having to download & install every dependency.

Recommended Read: Examples on how to use RPM command in Linux

Also Read: Beginner’s guide to Backup Postgres Database

In this tutorial, we will learn how to use the Yum command in Linux. Let’s see the syntax for using yum command in Linux.

Syntax:-

# yum -(options) package_name


Examples for using yum command in Linux

1- Install a package

To install a package, use the following command,

# yum install package_name

# yum install httpd


2- Install a package from the local system, http or ftp

If we have an rpm package available on the local system or we have an URL, we can also install it with yum,

# yum localinstall package_name.rpm

# yum localinstall http://xyz.com/package_name.rpm


3- Update package

To update a single package, the command is

# yum update httpd

To update all the installed packages on the system, use

# yum update

We can also update a package to a particular version with the option ‘update-to’.


4- Update only security-related packages

Rather than updating complete packages, we can only apply the updates to security related packages,

# yum update –security


5- Downgrade a package

To downgrade an installed package that has been updated previously, we can use the following command,

# yum downgrade package_name


6- Reinstall a package

To reinstall a package on the system, to address any issue that might have arisen due to misconfiguration or deletion of a file, use the following command,

# yum reinstall httpd


7- Remove a package

To remove a package, we can use either of the following two commands,

# yum remove httpd

OR

# yum erase httpd

There is another command to remove package & also remove other additional unneeded packages,

# yum autoremove httpd


8- Install a group of packages

To install a group of packages onto the system, use

# yum groupinstall ‘web server’

If you need to list down all the group packages, the command is,

# yum grouplist


9- List packages

To list all available packages from the repositories,

# yum list available

To list all installed packages,

# yum list installed

To list all available & installed packages,

# yum list all


10- Display package information

To display the complete information about a package,

# yum info vsftpd


11- Display dependencies for a package

To display a list of all dependencies required by a package,

# yum deplist vsftpd


12- Find packages for mentioned file

To get the name of packages for the mentioned file, use

# yum provides ‘/etc/httpd/conf/httpd.conf’


13- Search for package

To find packages with the search term in name & description , use

# yum search httpd


14- List updates information for packages

To list all the updated info, use

# yum updateinfo httpd


15- List yum repositories

To list down all the yum repositories enabled on the system,

# yum repolist

If we need information for the enabled repositories, we can use

# yum repoinfo repo_name


16- Check rpm database

To check the local rpm database for errors,

# yum check

Note:- This command runs for a long time.


17- Check yum history

To check the history for yum command, we can execute

# yum history list

This will provide list of all transactions with a serial number assigned to all transactions. These serial number can further be used to perform some operations like

List complete information for a transaction

# yum history info transaction_number

# yum history info 2

Undo a transaction

# yum history undo 2

Redo a transaction

# yum history redo 2


18- Download repo data to cache

To download yum repository data to cache, use

# yum makecache


19- Clear cached packages

To delete all packages saved in cache,

# yum clean packages

To completely clean packages & metadata from the cache,

# yum clean all


20- Get help

To list down all commands with options,

# yum help

With this we end our tutorial on how to use Yum command in Linux, please feel free to send in any questions or queries using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.