You are helping the user ensure that the APT package manager on Ubuntu is in good working health and remove any broken third-party repositories or packages.
Diagnoses APT package manager issues on Ubuntu by checking for broken packages, failing repositories, and dependency problems. Use this when apt commands fail or you need to clean up problematic third-party PPAs.
/plugin marketplace add danielrosehill/linux-desktop-plugin/plugin install lan-manager@danielrosehillYou are helping the user ensure that the APT package manager on Ubuntu is in good working health and remove any broken third-party repositories or packages.
Check basic APT functionality:
sudo apt updateapt-cache policyCheck for broken packages:
dpkg -l | grep "^..r"dpkg -l | grep "^..c"sudo dpkg --configure -asudo apt-get checkIdentify problematic repositories:
grep -r --include '*.list' '^deb ' /etc/apt/sources.list /etc/apt/sources.list.d/
sudo apt update 2>&1 | grep -i "fail\|error\|warning"
ls /etc/apt/sources.list.d/
Check APT cache integrity:
du -sh /var/cache/apt/archives/sudo apt-get clean
sudo apt-get autoclean
Fix broken dependencies:
sudo apt --fix-broken install
sudo dpkg --configure -a
sudo apt-get -f install
Identify and handle broken third-party repositories: For each failing repository found:
sudo add-apt-repository --remove ppa:<ppa-name>
sudo rm /etc/apt/sources.list.d/<repo>.listsudo sed -i 's/^deb/#deb/' /etc/apt/sources.list.d/<repo>.listCheck for GPG key issues:
sudo apt update 2>&1 | grep "NO_PUBKEY"
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <KEY>
apt-key listCheck for duplicate repositories:
grep -h "^deb " /etc/apt/sources.list /etc/apt/sources.list.d/* | sort | uniq -d
Check disk space:
df -h /varsudo apt-get clean
sudo apt-get autoclean
sudo apt-get autoremove
Check for held packages:
apt-mark showholdsudo apt-mark unhold <package-name>Verify repository configurations:
cat /etc/apt/sources.listCheck for obsolete packages:
aptitude search '~o'
apt list '~o'Verify package authentication:
grep -r "APT::Get::AllowUnauthenticated" /etc/apt/
Run full system check:
sudo apt-get checksudo apt-get -s upgradesudo apt-get -s dist-upgradeClean up:
sudo apt-get autoremovesudo apt-get cleansudo apt-get autocleanReset APT if severely broken: If APT is severely corrupted, may need to:
# Backup current sources
sudo cp -r /etc/apt /etc/apt.backup
# Reset dpkg
sudo dpkg --clear-avail
sudo apt-get update
# Reinstall base packages if needed
sudo apt-get install --reinstall apt dpkg
Check APT configuration files:
apt-config dump/etc/apt/apt.conf/etc/apt/apt.conf.d/Report findings: Summarize:
Provide recommendations:
sudo apt update && sudo apt upgrade
sudo apt autoremove
sudo apt clean