"bash: rpm: command not found"

Tired and ready for bed I accidentally deleted yum and rpm through the dependency magic of “yum –erase crontabs”.  Without rpm, how was I going to install rpm?  Since this was on a minimal image on a VPS I had few options:

1. Repair install from media – not an option on a cheapo VPS

2. rsync from identical remote machine – rsync wasn’t installed on local host

3. compile from from source – gcc not installed on local host

4. reset image to original on VPS – nope, that is admitting defeat

I ended up tarring up all the files from rpm and rpm-libs on an identical remote host and copying those over:

#on remote host send list of all files of the rpm and rpm-libs package into a temp file
rpm -ql rpm > /tmp/rpmList
rpm -ql rpm-libs >> /tmp/rpmList

#copy all the files into tarball
tar cvf rpm.tar `cat /tmp/rpmList`

#send tarball to broken machine
scp -P12345 rpm.tar root@remote:/

#untar and problem fixed
cd /
tar xvf rpm.tar