Useful yum commands

Those are some commands that you’ll probably need sometime to install, remove, update, etc. software in your CentOS/Fedora/Red Hat box. As I’m more used to apt-get I’ve searched a fairly complete list of tasks I’ll need in the future.


See installed packages:

yum list installed

Search for an installed package:

yum list installed | grep php

See available packages:

yum list available

Search for available packages:

yum list available | grep php

See information of a package:

yum info php
Name        : php
Arch        : x86_64
Version     : 5.3.3
Release     : 27.el6_5
Size        : 3.5 M
Repo        : installed

Install a package:

yum install package-name

Install a package without being asked for permission before installation process:

yum -y install package-name

Remove a package:

yum remove package-name

Remove a package without being asked for permission before removing process:

yum -y remove package-name

Remove orphan packages:

package-cleanup --quiet --leaves --exclude-bin | xargs yum remove -y

Check if a package has an update available:

yum check-update package-name

Update a package:

yum update package-name

See if any update is available:

yum check-update

Update everything:

yum update

Automatic updates

su -c '/sbin/chkconfig --level 345 yum on; /sbin/service yum start'

Note: There is no separate yum service that runs on your system. The command given above enables the control script /etc/rc.d/init.d/yum. This control script activates the script /etc/cron.daily/yum.cron, which causes the cron service to perform the system update automatically at 4am each day.

Add EPEL and Remi repositories:

For i686:

rpm -Uvh
rpm -Uvh

For x86_64:

rpm -Uvh
rpm -Uvh

Now you’ll see the new files that configure those repositories:

$ ls -1 /etc/yum.repos.d/

The Remi repository comes disabled by default so you’ll have to enable it by changing it’s enabled option to 1 or executing this command:

yum-config-manager --enable remi

Add ElRepo repository:

Import the public key:

rpm --import

Install the repo:

rpm -Uvh

Add RPMforge repository:

Import the GPG key:

rpm --import

Install for i686:

rpm -Uvh

Install for x86_64:

rpm -Uvh

Now you can install any software from that repository:

yum install htop

See available group of packages (for example MySQL is made by many packages):

yum grouplist
Installed Groups:
   Administration Tools
   DNS Name Server
   Dialup Networking Support
Available Groups:
   Authoring and Publishing

Install a grouplist:

yum groupinstall 'Beagle'

Update a grouplist:

yum groupupdate 'Beagle'

Remove a grouplist:

yum groupremove 'Beagle'

Clean the cache to delete files from /var/cache/yum

yum clean all

View the history of different installations, removes, etc.:

yum history
D     | Login user               | Date and time    | Action(s)      | Altered
   12 |  <user>                  | 2014-05-22 21:33 | Install        |    2
   11 |  <user>                  | 2014-05-22 21:31 | Install        |    3
   10 |  <user>                  | 2014-05-22 21:29 | Install        |    6
    9 |  <user>                  | 2014-05-22 21:05 | Install        |    4
    8 | System <unset>           | 2014-04-19 01:55 | I, U           |  117 EE
    7 | root <root>              | 2013-08-14 14:48 | I, U           |  156 EE
    6 | root <root>              | 2013-08-14 14:37 | Erase          |    1
    5 | System <unset>           | 2011-12-20 20:03 | I, U           |  162 EE
    4 | System <unset>           | 2011-07-10 19:29 | Install        |    3
    3 | System <unset>           | 2011-07-10 19:22 | Update         |   60  < 
    2 | System <unset>           | 2011-07-08 20:03 | Erase          |    6 > 
    1 | System <unset>           | 2011-07-08 20:43 | Install        |  276

To see a detailed information of an specific history operation use this command:

yum history info 11
Loaded plugins: fastestmirror
Transaction ID : 11
Begin time     : Thu May 22 21:31:08 2014
Begin rpmdb    : 292:63d8bb066751f0def9baf9c3aca697fa2dfaef21
End time       :            21:31:10 2014 (2 seconds)
End rpmdb      : 295:0f2bb4c03af71739f9be1f59c7bcfab9540de5d8
User           :  <user>
Return-Code    : Success
Command Line   : install php
Transaction performed with:
    Installed     rpm-4.8.0-37.el6.x86_64                         @base
    Installed     yum-3.2.29-43.el6.centos.noarch                 @updates
    Installed     yum-plugin-fastestmirror-1.1.30-17.el6_5.noarch @updates
Packages Altered:
    Install     php-5.3.3-27.el6_5.x86_64        @updates
    Dep-Install php-cli-5.3.3-27.el6_5.x86_64    @updates
    Dep-Install php-common-5.3.3-27.el6_5.x86_64 @updates

You can see in the “Packages Altered” area what packages were installed, deleted, updated or whatever.

See the list of configured repositories:

yum repolist
repo id                        repo name                                 status
base                           CentOS-6 - Base                           6.365+2
extras                         CentOS-6 - Extras                              14
updates                        CentOS-6 - Updates                          1.103
repolist: 7.482


You might also like

Delete backups after rpi-update
After installing rpi-update:sudo apt-get update sudo apt-get install rpi-updateAnd doing an...

MacPorts: Update port definitions and upgrade installed ports
Once in a while is good to update your software to get advantage of the latest bug fixes and new features....

Install software in unsupported Ubuntu versions with apt-get
When an Ubuntu version goes unsupported its repositories get moved to an archive server. If you don't...

Install Doctrine2 with PEAR in MacPorts
Run those commands:sudo /opt/local/bin/pear channel-discover sudo /opt/local/bin/pear...

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.