![我该如何在 Ubuntu 上删除所有可能损坏的软件包或重复的源?](https://linux22.com/image/1028703/%E6%88%91%E8%AF%A5%E5%A6%82%E4%BD%95%E5%9C%A8%20Ubuntu%20%E4%B8%8A%E5%88%A0%E9%99%A4%E6%89%80%E6%9C%89%E5%8F%AF%E8%83%BD%E6%8D%9F%E5%9D%8F%E7%9A%84%E8%BD%AF%E4%BB%B6%E5%8C%85%E6%88%96%E9%87%8D%E5%A4%8D%E7%9A%84%E6%BA%90%EF%BC%9F.png)
我想删除所有可能损坏的软件包,因为昨天我尝试下载 VM 和 lutris,但现在无法正常工作。我该如何改进?
我做了这个检查:
sudo apt-get check
和:
W: Target Packages (contrib/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:63 and /etc/apt/sources.list.d/virtualbox.list:2
W: Target Packages (contrib/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:63 and /etc/apt/sources.list.d/virtualbox.list:2
W: Target Translations (contrib/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list:63 and /etc/apt/sources.list.d/virtualbox.list:2
W: Target Translations (contrib/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:63 and /etc/apt/sources.list.d/virtualbox.list:2
W: Target DEP-11 (contrib/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:63 and /etc/apt/sources.list.d/virtualbox.list:2
W: Target DEP-11 (contrib/dep11/Components-all.yml) is configured multiple times in /etc/apt/sources.list:63 and /etc/apt/sources.list.d/virtualbox.list:2
W: Target DEP-11-icons-small (contrib/dep11/icons-48x48.tar) is configured multiple times in /etc/apt/sources.list:63 and /etc/apt/sources.list.d/virtualbox.list:2
W: Target DEP-11-icons (contrib/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:63 and /etc/apt/sources.list.d/virtualbox.list:2
W: Target DEP-11-icons-hidpi (contrib/dep11/[email protected]) is configured multiple times in /etc/apt/sources.list:63 and /etc/apt/sources.list.d/virtualbox.list:2
W: Target CNF (contrib/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list:63 and /etc/apt/sources.list.d/virtualbox.list:2
W: Target CNF (contrib/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list:63 and /etc/apt/sources.list.d/virtualbox.list:2
我不知道它们是什么意思。
答案1
使用此脚本:
#!/bin/bash
# Detect os codename
codename=$(awk '/UBUNTU_CODENAME=/' /etc/os-release | sed 's/UBUNTU_CODENAME=//' | sed 's/[.]0/./')
# Replace sources.list
text="deb http://archive.ubuntu.com/ubuntu/ $codename main universe restricted multiverse
deb-src http://archive.ubuntu.com/ubuntu/ $codename main universe restricted multiverse
deb http://security.ubuntu.com/ubuntu $codename-security main universe restricted multiverse
deb-src http://security.ubuntu.com/ubuntu $codename-security main universe restricted multiverse
deb http://archive.ubuntu.com/ubuntu/ $codename-updates main universe restricted multiverse
deb-src http://archive.ubuntu.com/ubuntu/ $codename-updates main universe restricted multiverse"
sudo echo "$text" | sudo tee /etc/apt/sources.list
# Start upgrade
sudo apt update
sudo apt install -f
sudo apt upgrade
sudo apt dist-upgrade
sudo apt autoremove --purge