零、修改源
我一般就之久用清華源。https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
備份一下/etc/apt/sources.list
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
然後
vim /etc/apt/sources.list
全部刪除修改爲下面的
# 默認註釋了源碼鏡像以提高 apt update 速度,如有需要可自行取消註釋
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
# deb-src 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-src 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-src 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
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# 預發佈軟件源,不建議啓用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
一、更新源和軟件:
sudo apt-get update
sudo apt-get upgrade
二、如果缺少公鑰
如果錯誤提示:
無法下載 https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/bionic-updates/InRelease:由於沒有公鑰,無法驗證下列簽名: NO_PUBKEY 3B4FE6ACC0B21F32
就安裝(注意缺少哪個公鑰就安裝哪個)
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3B4FE6ACC0B21F32
三、如果缺少軟件
如果錯誤提示
gpg: failed to start the dirmngr '/usr/bin/dirmngr': 沒有那個文件或目錄
就安裝
sudo apt-get install dirmngr