Ask Your Question
1

-bash: rpm: command not found

asked 2013-10-26 03:39:52 -0500

heye10 gravatar image

updated 2014-04-11 16:42:47 -0500

remjg gravatar image

I have accidentally removed rpm from centos 6.3 version 64-bit. How can I install it rpm back

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
2

answered 2013-10-26 16:13:17 -0500

Felix Schwarz gravatar image

This is a pretty bad situation but as long as you have the command line tools available, you should be able to rescue the situation.

  1. Are you sure that you removed the "rpm" rpm? I know this might sound stupid but if you only messed up your $PATH variable then the solution would be much easier (try running /bin/rpm --version - if you get something like RPM-Version 4.8.0 rpm is still there.)
  2. Is your rpm database intact? Check if you have the __db.00* files in /var/lib/rpm/. If you did loose your rpm database I guess you should reinstall your system/restore from backup.

Instead of compiling from source I'd recommend getting the binary RPM for your CentOS version and extract it manually.

# execute all following commands as root, especially "cpio" at the end
cd /
wget http://centos.bio.lmu.de/6/os/x86_64/Packages/rpm-4.8.0-32.el6.x86_64.rpm
rpm2cpio rpm-4.8.0-32.el6.x86_64.rpm | cpio -idmv

Now you should have an rpm command again.

edit flag offensive delete link more

Comments

After you've run this command, you should probably use the new rpm command to install the rpm package you just downloaded.

wquine gravatar imagewquine ( 2013-10-26 20:29:02 -0500 )edit
  1. I have removed "rpm" from bin directory
  2. From /var/lib/rpm/ I have found _db.00* files are present
  3. I have followed the command you have mentioned, executed as root but I am getting error rpm2cpio: error while loading shared libraries: librpm-4.3.so: wrong ELF class: ELFCLASS64 cpio: premature end of file I think i need rpm-4.3 version correct me if i am wrong
heye10 gravatar imageheye10 ( 2013-10-27 00:07:58 -0500 )edit
0

answered 2013-10-26 06:43:30 -0500

Bharat gravatar image

updated 2013-10-26 06:45:12 -0500

Get the sourcecode from www.rpm.org and compile it.

edit flag offensive delete link more

Comments

2

I don't think this is good advice. With such a critical component as rpm you should be 100% sure that you get exactly the rpm as Red Hat/CentOS built it. The CentOS "rpm-4.8.0-32.el6.src.rpm" contains 74 additional patches.

Felix Schwarz gravatar imageFelix Schwarz ( 2013-10-26 16:17:04 -0500 )edit
2

answered 2013-10-27 00:02:18 -0500

Akshay gravatar image

updated 2013-10-27 00:03:10 -0500

edit flag offensive delete link more

Comments

What a great link, I often wondered how to do that with no hassle. I've un-installed rpm and yum before by mistake, and it always lead to a reinstall of the system. It was responsible for me never using the '-y' option with 'yum remove ...' ever again.

cobra gravatar imagecobra ( 2013-10-28 04:57:36 -0500 )edit

Question Tools

Stats

Asked: 2013-10-26 03:39:52 -0500

Seen: 7,934 times

Last updated: Oct 27 '13