环境背景:
新装虚拟机上的centos7上什么都没有,基本的wget、vi、ifcong、rzsz等等基本命令都没有,搞了半天都没搞定,还好虚拟机能连上网,具体如下:
首先,检查虚拟机能不能连上网
ping一下百度看能否ping通,如果能连上网继续下面的操作,不能连上网找不能联网的解决办法跟本次报错主题无关了。
有数据说明ping通了
第一步,
查看有无 yum安装包 ,有的话卸载:(为了防止后面安装出错,先把可能冲突的东西卸载了)
查看:rpm -qa |grep yum
卸载:rpm -aq|grep yum|xargs rpm -e --nodeps
第二步,下载4个rpm包(根据自己安装的操作系统配置来下载,我装的是centos7)
下载地址:http://mirrors.163.com/centos/7/os/x86_64/Packages/
python-iniparse-0.4-9.el7.noarch.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-3.4.3-163.el7.centos.noarch.rpm
yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
说明:因为是超级干净的centos环境,什么命令都用不了,
所以这个下载可以先下载到自己物理机的本机上(非虚拟机),然后拖动上传到linux上。
这四个包的版本号可能跟我下载的不同,下载最新的就行。
第三步,
下载完成之后,用rpm命令进行安装,如下:
rpm -ivh --force --nodeps python-iniparse-0.4-9.el7.noarch.rpm
rpm -ivh --force --nodeps yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
rpm -ivh --force --nodeps yum-3.4.3-163.el7.centos.noarch.rpm
rpm -ivh --force --nodeps yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
这里安装的时候需要注意,一定要加 --force --nodeps不然会报错安装不上(具体原因咱也不知道,咱也不敢问,所有人都这么写至于原因为啥没人管呢)
都出现100%表示安装成功了
第四步,
输入yum命令,还是报No module named yum
第五步,
根据上图的提示到 http://yum.baseurl.org/wiki/
下载yum-3.4.3.tar.gz ,放到你指定的目录下解压,
还是先下载物理机本地,然后鼠标拖动到linux上来,rz waiting to receive.表示上传成功。
解压命令如下:
tar -zxvf yum-3.4.3.tar.gz
#解压后进到yum-3.4.3目录
输入如下命令
./yummain.py update 如下图:
注意中间有个输入
第六步,
以上rpm包安装完之后,在服务器中输入yum显示如下就表示安装成功可以使用yum命令了。
如果还有其他的问题在找其他的解决办法。
[root@localhost ~]# yum Loaded plugins: fastestmirror You need to give some command Usage: yum [options] COMMAND List of Commands: check Check for problems in the rpmdb check-update Check for available package updates clean Remove cached data deplist List a package‘s dependencies distribution-synchronization Synchronize installed packages to the latest available versions downgrade downgrade a package erase Remove a package or packages from your system groupinfo Display details about a package group groupinstall Install the packages in a group on your system grouplist List available package groups groupremove Remove the packages in a group from your system help Display a helpful usage message history Display, or use, the transaction history info Display details about a package or group of packages install Install a package or packages on your system list List a package or groups of packages load-transaction load a saved transaction from filename makecache Generate the metadata cache provides Find what package provides the given value reinstall reinstall a package repolist Display the configured software repositories resolvedep Determine which package provides the given dependency search Search package details for the given string shell Run an interactive yum shell update Update a package or packages on your system upgrade Update packages taking obsoletes into account version Display a version for the machine and/or available repos. Options: -h, --help show this help message and exit -t, --tolerant be tolerant of errors -C, --cacheonly run entirely from system cache, don‘t update cache -c [config file], --config=[config file] config file location -R [minutes], --randomwait=[minutes] maximum command wait time -d [debug level], --debuglevel=[debug level] debugging output level --showduplicates show duplicates, in repos, in list/search commands -e [error level], --errorlevel=[error level] error output level --rpmverbosity=[debug level name] debugging output level for rpm -q, --quiet quiet operation -v, --verbose verbose operation -y, --assumeyes answer yes for all questions --assumeno answer no for all questions --version show Yum version and exit --installroot=[path] set install root --enablerepo=[repo] enable one or more repositories (wildcards allowed) --disablerepo=[repo] disable one or more repositories (wildcards allowed) -x [package], --exclude=[package] exclude package(s) by name or glob --disableexcludes=[repo] disable exclude from main, for a repo or for everything --obsoletes enable obsoletes processing during updates --noplugins disable Yum plugins --nogpgcheck disable gpg signature checking --disableplugin=[plugin] disable plugins by name --enableplugin=[plugin] enable plugins by name --skip-broken skip packages with depsolving problems --color=COLOR control whether color is used --releasever=RELEASEVER set value of $releasever in yum config and repo files --downloadonly don‘t update, just download --downloaddir=DLDIR specifies an alternate directory to store packages --setopt=SETOPTS set arbitrary config and repo options Plugin Options:
对新手来说一句话没说清楚就有可能在坑里爬不起来,所以我要记下来太难了。
虚拟机上新装的centos7上没有yum命令-bash: yum: command not found报错的解决方法
原文:https://www.cnblogs.com/wenm1128/p/12679831.html