1.命令如下:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo chmod 777 sources.list
2.清空sources.list
echo "">/etc/apt/sources.list
3.将下列源路径粘贴到sources.list
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
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
4.更新
sudo apt-get update
经常在安装完系统后会出现运行apt-get update速度缓慢的问题,这里使用sed命令将原有的源替换为阿里云的源,以减少等待,具体 *** 作如下;
OS:Ubuntu16.04 LTS
1.ssh 登录到目标主机后运行如下命令
2.检查
运行 sudo apt-get update
linuxubuntu
apt-get更换源ubuntu
的默认源是美国的,所以下载起来特别慢,作为天朝用户,自然要更换为天朝的源了。国内有很多源可用,有些大学和公司也在维护着一些源。网上有很多可用的,下面给出一种简单的方法。用vi和gedit
打开
/etc/apt/sources.list
将其中的us.archive
全部替换为
cn.archive即可,这样,以后使用apt-get下载就会使用源自http://cn.archive.ubuntu.com
了。使用vi编辑器的命令为(注意首先切换到root用户):root@ubuntu
:/#vi
/etc/apt/sources.list打开sources.list在vi命令模式下(进入后即是命令行模式,按i后才可进入编辑模式,不过这里不需要编辑模式),输入:%s/us.archive/cn.archive/g替换完毕,输入:wq!保存退出。命令中的符号解释::(冒号),表示后面是命令%(百分号),表示修改缓冲区中的文件内容;也就是说如果不保存,源文件不会改变;所以之后要用:wq!
命令保存退出s(字母s),表示替换/us.archive/cn.archive,表示将文件中的us.archive
替换为cn.archive/g(撇加字母g),表示替换所有内容这样,就将apt-get的源更改为国内的源了。下面必须重起下apt-get,命令apt-get
update好了。经测试,北京网通速度很快,至于教育网或电信等,如果速度慢,可以找一些其它的源。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)