一、參考資料
ubuntu16.04更換鏡像源為阿里云鏡像源
二、相關(guān)介紹
1. apt常用命令
sudo apt-get clean
sudo apt-get update
2. APT加速工具
輕量小巧的零配置 APT 加速工具:APT Proxy
GitHub項目地址:apt-proxy
三、換源關(guān)鍵步驟
1. 更新阿里源
- 備份源配置文件。
cd /etc/apt/
cp sources.list sources.list.old
- 打開阿里云鏡像站:OPSX阿里云開源鏡像站,找到Ubuntu,點擊右邊的幫助,查看對應(yīng)版本的鏡像源信息。
相關(guān)配置
- 修改
sources.list
,更新鏡像源,更新倉庫信息。
# 修改sources.list配置文件
sudo gedit /etc/apt/sources.list
# 更新源
sudo apt-get update
# 更新倉庫信息
sudo apt-get upgrade
2. 更新清華源(可選)
# 清華源地址
https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/
四、FAQ
Q:ubuntu16.0.4bug無法解析域名
錯誤:1 http://mirrors.aliyun.com/ubuntu xenial InRelease
暫時不能解析域名“mirrors.aliyun.com”
錯誤:2 http://ppa.launchpad.net/fcitx-team/nightly/ubuntu xenial InRelease
暫時不能解析域名“ppa.launchpad.net”
錯誤:3 http://dl.google.com/linux/chrome/deb stable InRelease
暫時不能解析域名“dl.google.com”
錯誤:4 http://archive.ubuntukylin.com:10006/ubuntukylin xenial InRelease
暫時不能解析域名“archive.ubuntukylin.com”
錯誤:5 http://packages.microsoft.com/repos/vscode stable InRelease
暫時不能解析域名“packages.microsoft.com”
錯誤:6 http://archive.ubuntu.com/ubuntu wily InRelease
暫時不能解析域名“archive.ubuntu.com”
錯誤:7 http://mirrors.aliyun.com/ubuntu xenial-updates InRelease
暫時不能解析域名“mirrors.aliyun.com”
錯誤:8 http://ppa.launchpad.net/notepadqq-team/notepadqq/ubuntu xenial InRelease
暫時不能解析域名“ppa.launchpad.net”
0% [正在連接 mirrors.aliyun.com] [正在連接 ppa.launchpad.net]^C
參考博客: ubuntu16.0.4bug無法解析域名,注意查看網(wǎng)絡(luò)是否連接。
Q:無法對目錄 /var/lib/apt/lists/ 加鎖
正在讀取軟件包列表... 完成
E: 無法獲得鎖 /var/lib/apt/lists/lock - open (11: 資源暫時不可用)
E: 無法對目錄 /var/lib/apt/lists/ 加鎖
# 錯誤原因
在更新源時中途中斷了更新,系統(tǒng)給更新進程加鎖,所以只要再安裝軟件或者再去更新的時候就會出來的錯誤提示。
# 解決方法
sudo rm /var/lib/apt/lists/lock
或者
ps -e | grep apt-get # 查看apt-get進程
sudo kill -9 端口號 # 殺死進程
Q:換源警告
已下載 2,965 B,耗時 13分 18秒 (3 B/s)
正在讀取軟件包列表... 完成
W: 倉庫 “http://ppa.launchpad.net/kazam-team/stable-series/ubuntu xenial Release” 沒有 Release 文件。
N: 無法認證來自該源的數(shù)據(jù),所以使用它會帶來潛在風(fēng)險。
N: 參見 apt-secure(8) 手冊以了解倉庫創(chuàng)建和用戶配置方面的細節(jié)。
W: 倉庫 “https://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial Release” 沒有 Release 文件。
N: 無法認證來自該源的數(shù)據(jù),所以使用它會帶來潛在風(fēng)險。
N: 參見 apt-secure(8) 手冊以了解倉庫創(chuàng)建和用戶配置方面的細節(jié)。
W: 倉庫 “https://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial-updates Release” 沒有 Release 文件。
N: 無法認證來自該源的數(shù)據(jù),所以使用它會帶來潛在風(fēng)險。
N: 參見 apt-secure(8) 手冊以了解倉庫創(chuàng)建和用戶配置方面的細節(jié)。
W: 倉庫 “https://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial-backports Release” 沒有 Release 文件。
N: 無法認證來自該源的數(shù)據(jù),所以使用它會帶來潛在風(fēng)險。
N: 參見 apt-secure(8) 手冊以了解倉庫創(chuàng)建和用戶配置方面的細節(jié)。
W: 倉庫 “https://mirrors.tuna.tsinghua.edu.cn/ubuntu xenial-security Release” 沒有 Release 文件。
N: 無法認證來自該源的數(shù)據(jù),所以使用它會帶來潛在風(fēng)險。
N: 參見 apt-secure(8) 手冊以了解倉庫創(chuàng)建和用戶配置方面的細節(jié)。
# 錯誤原因:
具體原因尚不清楚,博主推測是清華源內(nèi)部的原因。
# 解決辦法:
換成阿里源,成功解決。
Q:dpkg: error processing package xxx (--configure) subprocess installed post-installation script returned error exit status 127
dpkg: error processing package *** (–configure)錯誤解決辦法
在 Ubuntu 執(zhí)行 sudo apt-get upgrade
或 sudo apt-get install
時,出現(xiàn)如上錯誤。這主要是由于不完全安裝導(dǎo)致的。解決方式是刪除或編輯安裝信息文件。
方法一(粗暴方法)
刪除所有信息,重新update。
sudo mv /var/lib/dpkg/info/ /var/lib/dpkg/info_old/
sudo mkdir /var/lib/dpkg/info/
sudo apt-get update
# 安裝修復(fù)
sudo apt-get install -f
方法二(精細方法)
查看出錯信息,定向刪除或編輯。
出錯信息 subprocess installed post-installation script returned error exit status 127
中,可以看到這里的提示post-installation的問題。文章來源:http://www.zghlxwxcb.cn/news/detail-758327.html
# 編輯該文件,具體在 `/var/lib/dpkg/info/[package_name].postinst`
# 或者刪除問題文件。例如:
sudo rm /var/lib/dpkg/info/[package_name].postinst
# 更狠一點
sudo mv /var/lib/dpkg/info /var/lib/dpkg/info.bak
sudo dpkg --configure -a
sudo apt-get update
Q:W: Failed to fetch xxx Could not handshake: A TLS fatal alert has been received. [IP: x.x.x.x 443]
W: Failed to fetch https://apt.repos.intel.com/mkl/dists/all/InRelease Could not handshake: A TLS fatal alert has been received. [IP: 219.76.10.117 443]
W: Some index files failed to download. They have been ignored, or old ones used instead.
# 錯誤原因:
外國源,無法訪問
# 解決辦法:
刪除外國源,重新update
sudo mv /var/lib/apt/lists /var/lib/apt/lists.bak
sudo apt-get update
Q:Certificate verification failed: The certificate is NOT trusted.
更換 Ubuntu 系統(tǒng) apt 命令安裝軟件源 文章來源地址http://www.zghlxwxcb.cn/news/detail-758327.html
Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown. Could not handshake: Error in the certificate verification.
# 解決辦法:
1. 編輯 /etc/apt/sources.list 文件,將 https 源修改為 http 源
https 是加密傳輸,需要證書認證。去掉 s,將 https 源修改為 http 源。
2. 更新證書 ca-certificates
sudo apt install ca-certificates
sudo apt-get install --reinstall ca-certificates
sudo apt install apt-transport-https ca-certificates
sudo apt-get update
3. 編輯 /etc/apt/sources.list 文件,將 http 源修改回 https 源
到了這里,關(guān)于Ubuntu apt-get換源的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!