-bash: yum: command not found 错误
在学习Linux时,误把yum命令给删除了,在百度了好几篇文章,但没能解决……............
查看有无 yum安装包 ,有的话卸载:
查看:rpm -qa |grep yum
卸载:rpm -aq|grep yum|xargs rpm -e --nodeps
第一步: 到这个网站去下载如下RPM包 :http://mirrors.163.com/centos/6/os/x86_64/Packages/
cd /etc/yum.repo.d/
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-cron-3.2.29-81.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm第二步:下载完成后安装:
rpm -ivh --force --nodeps python-urlgrabber-3.9.1-11.el6.noarch.rpm
rpm -ivh --force --nodeps yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
rpm -ivh --force --nodeps yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm yum-3.2.29-81.el6.centos.noarch.rpm注意:注意最后两个包必需同时安装,否则会相互依赖
第三步:下载阿里云的yum源:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
下载以后生成缓存,命令:
yum makecache
如果有提示错误,[Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
运行下面的命令:
sed -i 's/\$releasever/6/' CentOS-Base.repo
备注:把文件里的$releasever替换为6
最后:重新生成缓存,数字不为0,就OK了:
yum clean all
yum makecache