1: 备份Ubuntu默认的源地址
在终端输入:sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
2:更新源服务器列表
sudo gedit /etc/apt/sources.list
3:将弹出界面中的所有文字内容删除
4:从清华镜像源中寻找自己所需替换的镜像源
https://mirrors.tuna.tsinghua.edu.cn/
5:将找到的镜像源复制下来
20.04的镜像源:
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
18.04的镜像源:
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
6:粘贴到刚才删除的地方
7:更新源:
sudo apt-get update
①如果出现
W: 仓库 “https://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial Release” 没有 Release 文件。
N: 无法认证来自该源的数据,所以使用它会带来潜在风险。
N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。
则需要 更新软件源
sudo gedit /etc/apt/sources.list
ubuntu18.04—aliyun
deb http://mirrors.aliyun.com/ubuntu bionic main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu bionic-updates main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu bionic-security main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu bionic-proposed main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu bionic-backports main multiverse restricted universe
或者
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
ubuntu20.04-aliyun
deb http://mirrors.aliyun.com/ubuntu focal main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu focal-updates main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu focal-security main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu focal-proposed main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu focal-backports main multiverse restricted universe
或者
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
ubuntu16.04
deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe
sudo apt-get update
②W: 校验数字签名时出错。此仓库未被更新,所以仍然使用此前的索引文件。GPG 错误:http://packages.ros.org/ros/ubuntu bionic InRelease: 下列签名无效: EXPKEYSIG F42ED6FBAB17C654 Open Robotics info@osrfoundation.org
W: 无法下载 http://packages.ros.org/ros/ubuntu/dists/bionic/InRelease 下列签名无效: EXPKEYSIG F42ED6FBAB17C654 Open Robotics info@osrfoundation.org
W: 部分索引文件下载失败。如果忽略它们,那将转而使用旧的索引文件。
则需要更新公钥
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 23E7166788B63E1E
8:E: 无法获得锁 /var/lib/dpkg/lock-frontend - open (11: 资源暂时不可用) 的解决办法
sudo rm -r -f /var/lib/dpkg/lock-frontend
sudo rm -r -f /var/lib/dpkg/lock
相关命令:
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
检查是否有损坏的依赖
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)