Ask Your Question

-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

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 /
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


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: 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

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


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

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

Bharat gravatar image

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

Get the sourcecode from and compile it.

edit flag offensive delete link more



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

Question Tools


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

Seen: 7,934 times

Last updated: Oct 27 '13