Centos yum 修改为阿里源以及常用的命令

1、备份

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/

阿里源已失效,换为其他的源。

执行如下的命令:

[root@eshop-cache01 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://file.kangle.odata.cc/repo/Centos-6.repo

[root@eshop-cache01 yum.repos.d]# wget -O /etc/yum.repos.d/epel.repo http://file.kangle.odata.cc/repo/epel-6.repo

 

CentOS 5

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo

或者

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo

 

CentOS 6

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

或者

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo 

 

CentOS 7

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

3、之后运行yum makecache生成缓存

 

4、查看 linux 系统版本

[root@ca8a2d15ee41 yum.repos.d]# cat /etc/redhat-release 

CentOS Linux release 7.4.1708 (Core) 

 

5、yum 相关的命令

1)、安装命令

yum install -y package-name (-y 表示安装过程中的选项都选择 y,就是yes)

 

2)、查找提供安装包的名字

yum provides packagename

[root@ca8a2d15ee41 yum.repos.d]# yum provides ifconfig
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
net-tools-2.0-0.22.20131004git.el7.x86_64 : Basic networking tools
Repo        : base
Matched from:
Filename    : /sbin/ifconfig

net-tools-2.0-0.22.20131004git.el7.x86_64 : Basic networking tools
Repo        : @base
Matched from:
Filename    : /sbin/ifconfig

net-tools-2.0-0.22.20131004git.el7.x86_64 : Basic networking tools
Repo        : @base
Matched from:
Filename    : /usr/sbin/ifconfig

然后选择一个安装即可,比如 yum install -y net-tools-2.0-0.22.20131004git.el7.x86_64

posted @ 2018-01-09 00:35  竹子91  阅读(174)  评论(0编辑  收藏  举报