Ubuntu 16.04配置国内高速apt-get更新源

Ubuntu 16.04下载软件速度有点慢,因为默认的是从国外下载软件,那就更换到国内比较好的快速更新源(就是这些软件所在的服务器),一般直接百度Ubuntu更新源就能出来一大堆,这时候最好是找和自己Ubuntu版本一致的更新源,我的Ubuntu版本是16.04,下面是我找到的一个比较好的更新源。

1.寻找国内镜像源

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

2.配置source  list源

sources.list系统自带的,源是来Ubuntu的官网!安装包比较慢,所以最好切换成国内的

linuxidc.com@ubuntu:~$ cd /etc/apt
linuxidc.com@ubuntu:/etc/apt$ sudo cp sources.list sources.list.bak
linuxidc.com@ubuntu:/etc/apt$ vim sources.list                                                 

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse

3. 更新源

linuxidc.com@ubuntu:/etc/apt$ sudo apt-get update 
命中:1 http://mirrors.aliyun.com/ubuntu xenial InRelease
命中:2 http://mirrors.aliyun.com/ubuntu xenial-updates InRelease        
命中:3 http://mirrors.aliyun.com/ubuntu xenial-backports InRelease      
命中:4 http://mirrors.aliyun.com/ubuntu xenial-security InRelease        
正在读取软件包列表... 完成 

测试:安装sl包
linuxidc.com@ubuntu:/etc/apt$ sudo apt-get install sl

linuxidc.com@ubuntu:/etc/apt$ sl

4.其他一些命令

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 检查是否有损坏的依赖

### Ubuntu 16.04 上 `sudo apt-get install python2.5` 报错的原因分析 在 Ubuntu 16.04 中,默认支持 Python 的版本为 Python 2.7 和 Python 3.x。Python 2.5 并未被官方仓库所支持,因此尝试通过 `apt-get` 安装 Python 2.5 可能会遇到以下问题: #### 原因一:软件中不存在 Python 2.5 UbuntuAPT 包管理器依赖于其官方或第三方软件来获取软件包。由于 Python 2.5 是较旧的版本,在 Ubuntu 16.04 的默认软件中并未提供该版本的支持[^1]。 #### 原因二:依赖关系冲突 即使找到包含 Python 2.5 的自定义 PPA 或其他软件,也可能因为依赖项不匹配而导致安装失败。例如,某些依赖可能需要特定版本的库文件,而这些库文件在当前系统中并不存在或已被替换为高版本[^2]。 --- ### 解决方案 以下是几种可行的方法来解决此问题: #### 方法一:手动编译安装 Python 2.5 如果确实需要使用 Python 2.5,则可以通过下载其码并手动编译安装。具体操作如下: 1. 下载 Python 2.5 码: ```bash wget https://www.python.org/ftp/python/2.5/Python-2.5.tgz ``` 2. 解压并进入解压后的目录: ```bash tar -xvzf Python-2.5.tgz cd Python-2.5 ``` 3. 编译并安装: ```bash ./configure --prefix=/usr/local/python2.5 make sudo make install ``` 完成上述步骤后,可以运行 `/usr/local/python2.5/bin/python` 来启动 Python 2.5 环境[^3]。 #### 方法二:调整软件以启用旧版 Python 支持 虽然 Ubuntu 16.04 默认不支持 Python 2.5,但可以通过添加旧版存档(Old Releases)或其他社区维护的 PPA 来实现安装。然而需要注意的是,这种方法可能会引入安全风险或兼容性问题。 1. 修改软件列表: ```bash sudo sed -i 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list ``` 2. 新软件缓存: ```bash sudo apt-get update --fix-missing ``` 3. 尝试重新安装 Python 2.5(需确认是否有可用包): ```bash sudo apt-get install python2.5 ``` 注意:此方法的成功率较低,建议仅作为备选方案[^4]。 #### 方法三:隔离环境下的虚拟化部署 为了减少对现有系统的干扰,推荐使用容器技术(如 Docker)或虚拟机创建独立的开发环境,并在此环境中配置所需的 Python 版本。例如: 1. 创建基于 Ubuntu 16.04 的 Docker 镜像; 2. 手动安装 Python 2.5 或切换至早的操作系统版本(如 Debian Etch),其中仍保留对该版本的支持。 --- ### 注意事项 - **安全性考量**:Python 2.5 属于非常老旧的版本,已停止官方支持多年。继续使用此类版本可能导致严重的安全隐患。 - **替代方案**:评估项目需求,尽可能升级到受支持的 Python 版本(如 Python 2.7 或 Python 3.x)。这不仅能够提高程序稳定性,还能享受多现代功能和优化性能[^5]。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值