Useful yum commands

By | January 18, 2014

Red-Hat logoThe yum command is one of the most useful for Red-Hat/CentOS family server. It is basically  a command-line package-management utility.

Red-Hat/CentOS packages are provided as .rpm files which can be installed either using the rpm command, or with yum.

The nice thing about yum is that it allows you to add external repositories and you can install packages directly from there – yum even takes care of dependencies automatically. Pretty cool, right?

So, let’s see some nice ways on how you can use it.

How to install a new package using yum

Sure, this might seem a bit basic for some people, but hey, we all start somewhere:

yum install <package>

Pretty simple and fun:

[root@bubble ~]# yum install htop
Loaded plugins: downloadonly, fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.team-cymru.org
* epel: mirror.utexas.edu
* rpmforge: mirror.team-cymru.org
* updates: mirror.team-cymru.org
etting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package htop.x86_64 0:1.27-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================
Package Arch Version Repository Size
============================================================================================
Installing:
htop x86_64 1.0.2-1.el6 rpmforge 80 k

Transaction Summary
============================================================================================
Install 1 Package(s)

Total download size: 80 k
Installed size: 229 k
Is this ok [y/N]: y
Downloading Packages:
htop-1.0.2-1.el6.x86_64.rpm | 80 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : htop-1.0.2-1.el6.x86_64 1/1
Verifying : htop-1.0.2-1.el6.x86_64 1/1

Installed:
htop.x86_64 0:1.0.2-1.el6

Whoa, that’s a lot of text! So, what exactly happened? It looked for the htop package that we want to install on all the repositories we configured, it found the package, it looked for dependencies, downloaded all required packages and installed them. Pretty slick, right?

How to search for a package using yum

So, you want to install a package but you don’t know exactly how the developer named it? Search for it! No, you don’t need to Google it, you can search in your repositories using the yum search command:

[root@bubble ~]# yum search phpmyadmin
Loaded plugins: downloadonly, fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.team-cymru.org
* epel: mirror.utexas.edu
* extras: mirror.team-cymru.org
* remi: mirrors.mediatemple.net
* rpmforge: mirror.team-cymru.org
======= N/S Matched: phpmyadmin =======
phpMyAdmin.noarch : Handle the administration of MySQL over the World Wide Web
phpldapadmin.noarch : Web-based tool for managing LDAP servers
phpmyadmin.noarch : Web application to manage MySQL

Hurray, now you can install the package that you are looking for (and yes, packages are case-sensitive!).

How to update packages using yum

You can use yum to keep your packages up to date. With a simple yum update you can install the latest version for all your software:

[root@bubble ~]# yum update
Loaded plugins: downloadonly, fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.team-cymru.org
* epel: mirror.utexas.edu
* extras: mirror.team-cymru.org
* remi: mirrors.mediatemple.net
* rpmforge: mirror.team-cymru.org

Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package phpMyAdmin.noarch 0:4.1.4-1.el6.remi will be updated
---> Package phpMyAdmin.noarch 0:4.1.5-1.el6.remi will be an update
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================
Package Arch Version Repository Size
============================================================================================
Updating:
phpMyAdmin noarch 4.1.5-1.el6.remi remi 4.7 M

Transaction Summary
============================================================================================
Upgrade 1 Package(s)

Total download size: 4.7 M
Is this ok [y/N]: y
Downloading Packages:
phpMyAdmin-4.1.5-1.el6.remi.noarch.rpm | 4.7 MB 00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : phpMyAdmin-4.1.5-1.el6.remi.noarch 1/2
Cleanup : phpMyAdmin-4.1.4-1.el6.remi.noarch 2/2
Verifying : phpMyAdmin-4.1.5-1.el6.remi.noarch 1/2
Verifying : phpMyAdmin-4.1.4-1.el6.remi.noarch 2/2

Updated:
phpMyAdmin.noarch 0:4.1.5-1.el6.remi

Complete!

If you want to skip the interactive prompt, you can use yum update -y.

A similar command is yum upgrade which basically does the same, but it also takes obsolete packages into account.

If you want to update just some specific packages you can do just yum update <package(s)>.

How to download packages using yum

You can use yumdownloader to download (save) packages. Please see the yumdownloader tutorial on how to use it.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.