Common Symptoms
apt installreports “dependency not satisfied”dpkgis interrupted and cannot continue installation- “held broken packages” message appears
- Package status is “half-installed” or “half-configured”
Note
Most package issues can be resolved with the first three steps (dpkg --configure -a, apt --fix-broken install, apt update && apt upgrade). Please try them in order and do not rush to use advanced repair methods.
Standard Repair Procedure
Try the following steps in order. The first few steps usually resolve the issue.
Step 1: Fix interrupted dpkg
sudo dpkg --configure -aStep 2: Fix dependencies
sudo apt --fix-broken installStep 3: Update and clean up
sudo apt update
sudo apt upgrade
sudo apt autoremove
sudo apt autocleanAdvanced Repair
Force fix packages
# View problematic packages
dpkg -l | grep -E "^..[^i ]"
# Force reinstall a package
sudo apt install --reinstall PACKAGE_NAME
# Force remove a broken package
sudo dpkg --remove --force-remove-reinstreq PACKAGE_NAMEClear package cache
# Delete all downloaded package cache
sudo apt clean
# Delete only outdated packages
sudo apt autoclean
# Manual cleanup
sudo rm /var/cache/apt/archives/*.deb
sudo rm /var/cache/apt/archives/partial/*.debFix dpkg lock
If you get “Unable to lock the administration directory”:
# Check if other apt/dpkg processes are running
ps aux | grep -E "apt|dpkg"
# If you confirm no other processes are running, delete the lock files
sudo rm /var/lib/dpkg/lock-frontend
sudo rm /var/lib/dpkg/lock
sudo rm /var/cache/apt/archives/lock
sudo dpkg --configure -aRebuild dpkg database
In extreme cases where the dpkg database is corrupted:
# Back up existing database
sudo cp -r /var/lib/dpkg /var/lib/dpkg.backup
# Restore the status file from the system's daily backup (status is dpkg's core database)
ls -t /var/backups/dpkg.status.* # List available backup snapshots
sudo cp /var/backups/dpkg.status.0 /var/lib/dpkg/status # .0 is newest; use an older snapshot if needed
sudo dpkg --clear-avail
sudo apt updateDependency Conflict Troubleshooting
View package dependencies
# View dependencies of a package
apt depends PACKAGE_NAME
# View which packages depend on a package
apt rdepends PACKAGE_NAME
# Simulate installation to see conflicts
apt install -s PACKAGE_NAMEConflicts caused by PPAs
Third-party PPAs are a common source of dependency conflicts:
# List added PPAs
grep -rh "^deb " /etc/apt/sources.list.d/ | sort
# Disable a problematic PPA
sudo add-apt-repository --remove ppa:xxx/yyy
# Downgrade PPA-installed packages to official versions
sudo apt install ppa-purge
sudo ppa-purge ppa:xxx/yyyVersion hold conflicts
# View held packages
apt-mark showhold
# Unhold a package
sudo apt-mark unhold PACKAGE_NAMESnap Package Issues
# View snap status
snap list
# Fix snap
sudo snap refresh
# Reinstall a problematic snap
sudo snap remove PACKAGE_NAME
sudo snap install PACKAGE_NAMELast Resort
If none of the above methods work, try:
# Completely reinstall the package management system (use with caution)
sudo apt install --reinstall dpkg apt
# Or use aptitude for interactive conflict resolution
sudo apt install aptitude
sudo aptitude install PACKAGE_NAME
# aptitude will offer multiple solutions to choose fromPrevention Tips
- Avoid adding untrusted third-party PPAs
- Do not mix software sources from different Ubuntu versions
- Regularly run
sudo apt update && sudo apt upgrade - Use
apt install -sto simulate installation and check for conflicts - Keep system package versions consistent; avoid manually installing
.debfiles that override system packages
Last updated on