Share, , Google Plus, Pinterest,

Print

Posted in:

Working with YUM on CentOS 6

Yum or Yellowdog Updater Modified is a command line package management solution for Linux systems using RPM‘s like Red Hat Enterprise Linux, CentOS Linux, Fedora,… We can use yum to search, install, remove and check for additional information about RPM packages available to our Linux system.

Yum works with local or remote repositories which are some kind of RPM package warehouses. Each repository has a list of RPM packages available which we can manipulate with yum command. There are many options to use with yum command depending on what we want to do. In this article we will explain how to use yum command and it’s options on you Linux systems.

Install RPM with YUM
Install RPM with YUM

Why Yum?

Because Yum automatically resolves dependencies for specific RPM package and installs them on your Linux system if they are available from configured repositories.

Yum Repositories

Yum repositories are RPM package warehouses. Repository holds a number of RPM package files and shares these files via HTTP or other similar protocol to it’s clients. Client computers usually use remote yum repositories accessible through network. By default Linux system comes with pre-installed official repositories (Official CentOS mirrors, Official Fedora mirrors,… RHEL mirrors are naturally licensed) but if you want you can add some additional third-party repositories.

Some of the most known additional repositories are:

Yum stores repository information and configuration files in /etc/yum.repos.d/ directory. Repository configuration files must end with .repo and hold all neccessary information to access the repository.

Sample minimal custom repository configuration file is:

[custom]
name=custom repository
baseurl=http://hostname.domain/repository
enabled=1
gpgcheck=0

Yum Commands

Yum commands are used in concatenation with “yum”. The syntax is:

yum <command> <package/s>
  • check-update

This command checks all configured repositories if any updates are available for packages installed on your system. If updates are available a list is provided with package names, update versions and repository name:

[root@foo1 ~]# yum check-update
  • clean

Yum clean command removes client cached data. It requires an option to specify what to clean – available options are: headers, packages, metadata, dbcache, plugins, expire-cache, rpmdb, all. It is preferred to run clean command after changing repository configuration to clear all cache data from previous configurations:

[root@foo1 ~]# yum clean all
  • deplist

This command lists the dependencies for the provided package. It requires you to specify the name of the package you want to get the list of dependencies for:

[root@foo1 ~]# yum deplist telnet
  • downgrade

This command downgrades package to the last available version – ONLY if downgrade for package is available! Most often when using official repositories only upgrades are available – in below scenario Spacewalk patch management system was used providing older versions of certain packages. Downgrade command requires you to specify the name the package you want downgrade:

[root@foo1 ~]# yum downgrade pixman
  • erase or remove

Erase and remove commands are user to completely remove specific packages and it’s dependencies from the Linux system. This command requires you to specify the name of the package you want to erase:

[root@foo1 ~]# yum erase pixman
  • grouplist

Grouplist lists available package groups from configured repositories. Package groups are groups of RPM packages providing full functionality of some kind:

[root@foo1 ~]# yum grouplist
  • groupinfo

Groupinfo command provides information about the specific package group. This command requires you to specify the name of the group you want to get information about:

[root@foo1 ~]# yum groupinfo "Backup Server"
  • groupinstall

Groupinstall command allows you to install specific group of packages on your Linux system. This command requires you to specify the name of the group of packages you want to install:

[root@foo1 ~]# yum groupinstall "Backup Server"
  • groupremove

Groupremove command removes specific group of packages from your Linux system. This command requires you to specify the name of the group of packages you want to remove:

[root@foo1 ~]# yum groupremove "Backup Server"
  • info

Info command provides additional information (name, version,description,…) about the specific package. This command requires you to specify the name of the package you want to get information about:

[root@foo1 ~]# yum info pixman
  • install

This command enables you to install specific package and it’s dependencies on your Linux system. This command requires you to specify the name of the package or packages you want to install:

[root@foo1 ~]# yum install pixman
  • list

This command lists package names, versions and repository location for specific packages. List has additional options like all, available, updates, installed,… This command requires you to specify the name of the package or packages you want to list:

[root@foo1 ~]# yum list kernel
  • localinstall

Localinstall is very useful command since it enables to install locally provided RPM packages and resolve it’s dependencies from configured repositories. This command requires you to specify the path to the RPM package we want to install:

[root@foo1 ~]# yum localinstall createrepo-0.9.9-17.el6.noarch.rpm
  • localupdate

Command localupdate is used to update the Linux system specifying local RPM package files. Only the specified rpm files of which an older version is already installed will be installed, the remaining specified packages will be ignored. This command requires you to specify the path where RPM package files are located:

[root@foo1 ~]# yum localupdate /repo
  • provides or whatprovides

Provides command is same as whatprovides and is very useful since we can check which package provides certain files or features. This command requires you to specify the file or feature location:

[root@foo1 ~]# yum provides /etc/login.defs
  • reinstall

Reinstall command allows us to reinstall specific package. This command requires you to specify the name of the package or packages you want to reinstall:

[root@foo1 ~]# yum reinstall pixman
  • repolist

Repolist command provides us with the information about the configured repositories on your Linux system:

[root@foo1 ~]# yum repolist
  • resolvedeps

Resolvedeps command is used to list packages providing the specified dependencies. This command requires you to specify the file location:

[root@foo1 ~]# yum resolvedep /etc/login.defs
  • search

Search command enables you to search for specific packages, package names from configured repositories. This command requires you to specify package name:

[root@foo1 ~]# yum search httpd
  • update

Update command is used to update specific packages. If command specified without any package names it will update every currently installed package:

[root@foo1 ~]# yum update
  • upgrade

Upgrade command is the same as update but with –obsolete flag set which means it will take obsoletes into account:

[root@foo1 ~]# yum upgrade

This is it! You are now ready to install and remove packages from your RHEL based Linux systems!