centos7 更换国内yum源
时间: 2023-08-07 08:03:07 浏览: 112
您可以按照以下步骤更换CentOS 7的国内yum源:
1. 备份原有的yum源配置文件:
```shell
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
```
2. 下载新的yum源配置文件:
```shell
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
```
3. 清除yum缓存:
```shell
sudo yum clean all
```
4. 生成新的缓存:
```shell
sudo yum makecache
```
现在您的CentOS 7系统已经成功更换为国内的yum源了。
相关问题
centos7更换国内yum源
更换CentOS 7的国内yum源的步骤如下:
1. 首先备份系统自带yum源配置文件:在终端输入以下命令备份文件:
```shell
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
```
2. 下载国内yum源配置文件到/etc/yum.repos.d/目录下:根据需要选择阿里云源或网易云源。在终端输入以下命令下载阿里云源配置文件:
```shell
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
```
或者输入以下命令下载网易云源配置文件:
```shell
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
```
3. 清理yum缓存,并生成新的缓存:在终端输入以下命令以清理缓存并生成新的缓存:
```shell
yum clean all
yum makecache
```
4. 检查是否成功更换yum源:在终端输入以下命令以更新yum源并检查是否生效:
```shell
yum update
```
注意:如果只想更新软件包而不更新内核,可以在yum命令后加上参数`--exclude=kernel*`,例如:
```shell
yum --exclude=kernel* update
```
以上就是更换CentOS 7的国内yum源的步骤。可以根据自己的需求选择合适的国内yum源进行替换。
CentOS7更换国内yum源
在 CentOS 7 中,您可以通过以下步骤更换为国内的 yum 源:
1. 备份原有的 yum 源配置文件:
```
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
```
2. 下载国内的 yum 源配置文件,例如阿里云的 yum 源:
```
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
```
3. 清除 yum 缓存:
```
yum clean all
```
4. 生成 yum 缓存:
```
yum makecache
```
完成上述步骤后,您就可以使用国内的 yum 源来安装和更新软件包了。如果您想恢复原有的 yum 源配置文件,只需要运行以下命令即可:
```
mv /etc/yum.repos.d/CentOS-Base.repo.backup /etc/yum.repos.d/CentOS-Base.repo
```