linux更换源

1、ubuntu 更换源

以ubuntu16.04为例

(1)cp /etc/apt/sources.list /etc/apt/sources.list.bak           //备份系统原有的源

(2)vi /etc/apt/sources.list       //将文件内容改为如下对应需要的源的内容

阿里源:

# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

 

 

网易163源:

deb http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse

deb http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse

(3)sudo apt-get update       //更新源

(4)sudo apt-cache search 命令   //当不知道对应命令需要下载的软件包的名称时,可以使用该命令进行查找  ,如 sudo apt-cache search xfreerdp

(5)sudo apt-get install 软件名     //下载对应的软件 , 如sudo apt-get install freerdp

 

 

2、Centos 更换源

以centos7.2为例

 

(1) cd  /etc/yum.repos.d       //进入yum源配置文件所在文件夹
(2) mv  CentOS-Base.repo  CentOS-Base.repo.bak      //备份原有的源文件
(3) 下载对应的yum源文件
    163源:wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
    阿里源:wget http://mirrors.aliyun.com/repo/Centos-7.repo
    将文件改名为 :CentOS-Base.repo
(4) yum  clean  all           //清理缓存
(5) yum  makecache         //重新生成缓存
(6) yum  -y  update         //更新系统
(7) yum  -y  install  软件名     //下载对应的软件 , 如yum -y install vim

遇到的问题处理:

1、在centos更换源,执行  yum -y update 的时候报了如下错

Error:  Multilib version problems found. This often means that the root
       cause is something else and multilib version checking is just
       pointing out that there is a problem. Eg.:
       
         1. You have an upgrade for libgcc which is missing some
            dependency that another package requires. Yum is trying to
            solve this by installing an older version of libgcc of the
            different architecture. If you exclude the bad architecture
            yum will tell you what the root cause is (which package
            requires what). You can try redoing the upgrade with
            --exclude libgcc.otherarch ... this should give you an error
            message showing the root cause of the problem.
       
         2. You have multiple architectures of libgcc installed, but
            yum can only see an upgrade for one of those architectures.
            If you don't want/need both architectures anymore then you
            can remove the one with the missing update and everything
            will work.

这是因为libgcc有重复的软件包,解决如下

[root@localhost yum.repos.d]# rpm -q libgcc   //查处gcc的软件包
libgcc-4.8.5-4.el7.x86_64
libgcc-4.8.5-36.el7_6.2.x86_64
[root@localhost yum.repos.d]# rpm -e libgcc-4.8.5-4.el7.x86_64   //删除其中一个软件包

 

  • 3
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值