Ubuntu 更新源

清华大学镜像源

https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/

备份原文件

cp -a /etc/apt/sources.list{,-bak}

vi /etc/apt/sources.list


Ubuntu16.04 LTS

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

Ubuntu 18.04:(bionic)

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-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed 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

更新

apt update

# 如果报错:
W: UNKNOWN MULTI-ARCH TYPE 'NO' FOR PACKAGE 'COMPIZ-GNOME'...

# 执行:
apt-get install -f apt

apt 常用命令

# 更新源
sudo apt-get update
# 安装包
sudo apt-get install package
# 删除包
sudo apt-get remove package
# 搜索软件包
sudo apt-cache search package
# 获取包的相关信息,如说明、大小、版本等
sudo apt-cache show package
# 重新安装包
sudo apt-get install package --reinstall
# 修复安装
sudo apt-get -f install
# 删除包,包括配置文件等
sudo apt-get remove package --purge
# 安装相关的编译环境
sudo apt-get build-dep package
# 更新已安装的包
sudo apt-get upgrade
# 升级系统
sudo apt-get dist-upgrade
# 了解使用该包依赖那些包
sudo apt-cache depends package
# 查看该包被哪些包依赖
sudo apt-cache rdepends package
# 下载该包的源代码
sudo apt-get source package
# 清理无用的包
sudo apt-get clean && sudo apt-get autoclean
# 检查是否有损坏的依赖
sudo apt-get check