CentOS / RHEL: yum Command Reinstall Package

by on December 30, 2011 · 3 comments· LAST UPDATED December 30, 2011

in

I accidental deleted the configuration file stored in /etc/ directory and the latest backup were made yesterday. How do I resinstall the package using the yum command under RHEL / CentOS Linux server?

You can use the yum command with reinstall option. This will reinstall the identically versioned package as is currently installed. The syntax is as follows:

 
yum reinstall packageName
yum reinstall packageName1 packageName2
 

In this example reinstall a package called keepalived, type:
# yum reinstall keepalived
Sample outputs:

Loaded plugins: product-id, rhnplugin, subscription-manager
Updating certificate-based repositories.
Setting up Reinstall Process
Resolving Dependencies
--> Running transaction check
---> Package keepalived.x86_64 0:1.2.2-2.el6 will be reinstalled
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================================================
 Package                             Arch                            Version                                 Repository                     Size
=================================================================================================================================================
Reinstalling:
 keepalived                          x86_64                          1.2.2-2.el6                             epel                          147 k
Transaction Summary
=================================================================================================================================================
Reinstall     1 Package(s)
Total download size: 147 k
Installed size: 380 k
Is this ok [y/N]: y
Downloading Packages:
keepalived-1.2.2-2.el6.x86_64.rpm                                                                                         | 147 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : keepalived-1.2.2-2.el6.x86_64                                                                                                 1/1
Installed products updated.
Installed:
  keepalived.x86_64 0:1.2.2-2.el6

Note: This does not work for "installonly" packages such as RHEL kernels packages.

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 3 comments… read them below or add one }

1 ron December 31, 2011 at 4:17 am

this is from fedora 16:

+++

[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3
clean_requirements_on_remove = 1

# This is the default, if you make this bigger yum won’t see if the metadata
# is newer on the remote and so you’ll “gain” the bandwidth of not having to
# download the new metadata and “pay” for it by yum not having correct
# information.
# It is esp. important, to have correct metadata, for distributions like
# Fedora which don’t keep old packages around. If you don’t like this checking
# interupting your command line usage, it’s much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

+++

Reply

2 amir tal November 4, 2012 at 12:22 pm

this does not work.
yum does not have such an option “reinstall”

usage: yum [options]

options:
-h, –help show this help message and exit
-t, –tolerant be tolerant of errors
-C run entirely from cache, don’t update cache
-c [config file] config file location
-R [minutes] maximum command wait time
-d [debug level] debugging output level
-e [error level] error output level
-q, –quiet quiet operation
-v, –verbose verbose operation
-y answer yes for all questions
–version show Yum version and exit
–installroot=[path] set install root
–enablerepo=[repo] enable one or more repositories (wildcards allowed)
–disablerepo=[repo] disable one or more repositories (wildcards allowed)
-x [package], –exclude=[package]
exclude package(s) by name or glob
–disableexcludes=[repo]
disable exclude from main, for a repo or for
everything
–obsoletes enable obsoletes processing during updates
–noplugins disable Yum plugins
–nogpgcheck disable gpg signature checking
–disableplugin=[plugin]
disable plugins by name

nope.. no reinstall here…

Reply

3 amir tal November 4, 2012 at 12:23 pm

nevermind… thats an old version…

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , ,

Previous Faq:

Next Faq: