Removed YUM? CentOS 5.5

After doing yum remove crontabs this appears after running yum: -bash: /usr/bin/yum: No such file or directory

This was the output of yum remove crontabs:

[root@vs270 opt]# yum remove crontabs
Loaded plugins: fastestmirror
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package crontabs.noarch 0:1.10-8 set to be erased
--> Processing Dependency: crontabs for package: rpm
--> Running transaction check
---> Package rpm.x86_64 0:4.4.2.3-20.el5_5.1 set to be erased
--> Processing Dependency: rpm = 4.4.2.3-20.el5_5.1 for package: rpm-python
--> Processing Dependency: rpm = 4.4.2.3-20.el5_5.1 for package: rpm-libs
--> Processing Dependency: rpm >= 3.0.5 for package: apt
--> Processing Dependency: rpm >= 4.4.2 for package: yum
--> Running transaction check
---> Package apt.x86_64 0:0.5.15lorg3.94a-5.el5.rf set to be erased
---> Package rpm-libs.x86_64 0:4.4.2.3-20.el5_5.1 set to be erased
---> Package rpm-python.x86_64 0:4.4.2.3-20.el5_5.1 set to be erased
---> Package yum.noarch 0:3.2.22-26.el5.centos set to be erased
--> Processing Dependency: yum >= 3.0 for package: yum-fastestmirror
--> Running transaction check
---> Package yum-fastestmirror.noarch 0:1.1.16-14.el5.centos.1 set to be erased
--> Processing Dependency: /bin/rpm for package: policycoreutils
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package policycoreutils.x86_64 0:1.33.12-14.8.el5 set to be erased
--> Processing Dependency: policycoreutils >= 1.33.12-14.5 for package: selinux-policy
--> Processing Dependency: policycoreutils for package: setools
--> Running transaction check
---> Package selinux-policy.noarch 0:2.4.6-279.el5_5.2 set to be erased
---> Package setools.x86_64 0:3.0-3.el5 set to be erased
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================================================================
 Package                                           Arch                                   Version                                                   Repository                                     Size
====================================================================================================================================================================================================
Removing:
 crontabs                                          noarch                                 1.10-8                                                    installed                                 1.0 k
Removing for dependencies:
 apt                                               x86_64                                 0.5.15lorg3.94a-5.el5.rf                                  installed                                      8.5 M
 policycoreutils                                   x86_64                                 1.33.12-14.8.el5                                          installed                                     2.1 M
 rpm                                               x86_64                                 4.4.2.3-20.el5_5.1                                        installed                                     3.6 M
 rpm-libs                                          x86_64                                 4.4.2.3-20.el5_5.1                                        installed                                     2.0 M
 rpm-python                                        x86_64                                 4.4.2.3-20.el5_5.1                                        installed                                     131 k
 selinux-policy                                    noarch                                 2.4.6-279.el5_5.2                                         installed                                     7.5 M
 setools                                           x86_64                                 3.0-3.el5                                                 installed                                     3.3 M
 yum                                               noarch                                 3.2.22-26.el5.centos                                      installed                                     3.2 M
 yum-fastestmirror                                 noarch                                 1.1.16-14.el5.centos.1                                    installed                                      47 k

Transaction Summary
====================================================================================================================================================================================================
Remove       10 Package(s)
Reinstall     0 Package(s)
Downgrade     0 Package(s)

Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing        : crontabs                                                                                                                                                                        1/10 
  Erasing        : rpm-python                                                                                                                                                                      2/10 
  Erasing        : yum                                                                                                                                                                             3/10 
warning: /etc/yum.conf saved as /etc/yum.conf.rpmsave
  Erasing        : apt                                                                                                                                                                             4/10 
warning: /etc/apt/sources.list.d/os.list saved as /etc/apt/sources.list.d/os.list.rpmsave
  Erasing        : rpm                                                                                                                                                                             5/10 
  Erasing        : selinux-policy                                                                                                                                                                  6/10 
  Erasing        : policycoreutils                                                                                                                                                                 7/10 
  Erasing        : rpm-libs                                                                                                                                                                        8/10 
  Erasing        : yum-fastestmirror                                                                                                                                                               9/10 
  Erasing        : setools                                                                                                                                                                        10/10 

Removed:
  crontabs.noarch 0:1.10-8                                                                                                                                                                          

Dependency Removed:
  apt.x86_64 0:0.5.15lorg3.94a-5.el5.rf                     policycoreutils.x86_64 0:1.33.12-14.8.el5         rpm.x86_64 0:4.4.2.3-20.el5_5.1         rpm-libs.x86_64 0:4.4.2.3-20.el5_5.1        
  rpm-python.x86_64 0:4.4.2.3-20.el5_5.1                    selinux-policy.noarch 0:2.4.6-279.el5_5.2         setools.x86_64 0:3.0-3.el5              yum.noarch 0:3.2.22-26.el5.centos           
  yum-fastestmirror.noarch 0:1.1.16-14.el5.centos.1        

Complete!

Any ideas on how to re-install YUM without YUM itself? Thanks :D


It's possible to install RPM by unpacking the files from the RPM-rpm (uhuh) package. This will get you going again and you will be able to install yum as well. First create the directory you are going to use for unpacking the files from the RPM archive and download the RPM package.

mkdir /tmp/becarefulnexttime
cd /tmp/becarefulnexttime
wget http://ftp.tudelft.nl/centos.org/5/os/x86_64/CentOS/rpm-4.4.2.3-22.el5.x86_64.rpm

Make sure you download the RPM version corresponding to your CentOS version / architecture, but looking at your yum output I think this is.

Now, extract the files from the RPM archive and copy the important files to your CentOS installation root.

rpm2cpio rpm-4.4.2.3-22.el5.x86_64.rpm | cpio -dim
find . -type d -exec chmod 755 {} \;
tar cf - ./usr ./etc | (cd /; tar xvf -)

You should have a working rpm command now, rebuild the RPM database and install RPM properly:

rpm --rebuilddb
rpm -i rpm-4.4.2.3-22.el5.x86_64.rpm

You might need some extra dependencies you removed earlier but it should now be possible to install yum again

rpm -i http://ftp.tudelft.nl/centos.org/5/os/x86_64/CentOS/yum-3.2.22-33.el5.centos.noarch.rpm

You could probably recompile the rpm package manually, install that, then install yum, but unless this is a mission-critical box it'd be quicker to backup your configuration and reinstall, probably.