linux修改YUM源
将原来的文件进行备份,避免在修改失败的时候失去原来的配置;
1、mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
在阿里开源镜像站中找到对应的版本,本次以CentOS7为例,其他的版本,在版本号上会有不同;下载新的CentOS-Base.repo到/etc/yum.repos.d目录,执行下列目录会自动进行现在。前提是服务器可以正常连接网络。
2、下载文件
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
若使用wget偶尔会提示command not found,这时使用curl即可。
3、运行
yum makecache
生成缓存;
4、没有可用软件包 htop。
错误:无须任何处理
yum install epel-release
然后再试试yum install 其他安装包