-bash: /usr/bin/yum: 没有那个文件或目录

一、原因

出现这个的原因是我们把yum给删除掉或者卸载掉了  ,这时候我们只需要重新安装即可,具体步骤如下:

二、查看系统新建目录

1、查看自己的系统版本

RedHat系列:

常见系统有:Redhat、Centos、Fedora等

我的是centos  查看系统命令如下:

cat /etc/redhat-release

2、新建目录

1 mkdir /usr/local/src/python
2 mkdir /usr/local/src/yum

3、下载yum源

cd /usr/local/src/yum  

rpm -ivh --nodeps http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

rpm -ivh --nodeps http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm

rpm -ivh --nodeps http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm

4、下载python依赖

cd /usr/local/src/python

wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-2.7.5-34.el7.x86_64.rpm
wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-pycurl-7.19.0-17.el7.x86_64.rpm
wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-devel-2.7.5-34.el7.x86_64.rpm
wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-libs-2.7.5-34.el7.x86_64.rpm
wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/python-urlgrabber-3.10-7.el7.noarch.rpm
wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/rpm-python-4.11.3-17.el7.x86_64.rpm

三、安装python和yum

1、安装python

rpm -ivh python-* rpm-python-* 

#可能会出现以下报错

[root@node2 python]# rpm -ivh python-* rpm-python-*
错误:依赖检测失败:
        rpm = 4.11.3-17.el7 被 rpm-python-4.11.3-17.el7.x86_64 需要

意思就是说缺少依赖   这里我是选择强制安装  没有再去安装相关依赖 也可以把相关的依赖都安装上

2、忽略依赖安装

rpm -ivh python-* rpm-python-* --nodeps --force   # --nodeps --force为不考虑依赖包,强制安装。

安装完后即可运行python

3、安装yum

cd /usr/local/src/yum

rpm -ivh yum-*

如果提示缺少依赖包

同上安装python一样  强制前安装即可

rpm -ivh yum-* --nodeps --force

运行yum,问题完美解决