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.
🐧 3 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
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
+++
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…
nevermind… thats an old version…