ubuntu系统默认的软件源更新速度非常慢,一般装完系统后,我都会将软件源更改成国内的软件源。ubuntu软件源配置文件为/etc/apt/sources.list。显然我们要修改这个文件要有root权限。首先切换为root用户(这样省得每次都要sudo)
jie$ su
Password:
root$ cd /etc/apt
root$ ls
apt.conf.d sources.bak trusted.gpg trusted.gpg.d
preferences.d sources.list sources.list.d trusted.gpg~为了防止操作失误,最好将sources.list备份一下:
root$ cp sources.list sources.list.backup
root$ cat sources.list
#deb cdrom:[Ubuntu 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.2)]/ xenial main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ xenial universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial universe
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu xenial partner
# deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://security.ubuntu.com/ubuntu xenial-security main restricted
# deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
deb http://security.ubuntu.com/ubuntu xenial-security universe
# deb-src http://security.ubuntu.com/ubuntu xenial-security universe
deb http://security.ubuntu.com/ubuntu xenial-security multiverse
# deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse其它更改软件源只需将sources.list中的http://security.ubuntu.com/ubuntu替换为http://mirrors.163.com/ubuntu/即可,使用sed编辑器:
root$ sed s?http://security.ubuntu.com/ubuntu?http://mirrors.163.com/ubuntu/?g sources.list > temp.txt
root$ cp temp.txt sources.list这样就完成软件源的替换。这样再执行apt-get update 命令时,就会从网易软件源中更新。
root$ apt-get update
Hit:1 http://mirrors.163.com/ubuntu xenial InRelease
Hit:2 http://mirrors.163.com/ubuntu xenial-updates InRelease
Hit:3 http://mirrors.163.com/ubuntu xenial-backports InRelease
Hit:4 http://mirrors.163.com/ubuntu xenial-security InRelease
Get:5 https://get.daocloud.io/docker/apt-repo ubuntu-xenial InRelease [46.9 kB]
Fetched 46.9 kB in 1s (38.6 kB/s)
Reading package lists... Done可以看到这次同步软件源使用的是网易163源。
版权声明:本文为guoyajie1990原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。