How to fix broken packages in Ubuntu via Terminal. To do so list broken packages in Ubuntu and then Ubuntu users can fix broken packages via command line. If a package installation fails in Linux Ubuntu, it can cause few problems. For example, the package manager freezes or become locked. It is a bit problem to use Ubuntu properly while the system packages are broken or corrupt. Luckily, there are few ways to resolve the issue.
Fix broken packages using Ubuntu terminal
If you know the name of the broken package, you can remove it manually using the following command.
sudo dpkg --remove -force --force-remove-reinstreq PACKAGE_NAME_GOES_HERE
If you aren’t sure about the name of the broken package, follow the commands given below:
Command 1
sudo apt-get --fix-broken install
Command 2
If a Ubuntu package installation fails (due to dependencies), run the following command
sudo apt-get clean
sudo apt-get install -f
sudo dpkg --configure -a
sudo apt-get update
Command 3
sudo rm /var/lib/apt/lists/* -vf
sudo apt-get update
Command 4
sudo apt-get clean
sudo apt-get autoclean
sudo apt-get autoremove
Command 5
sudo dpkg --configure -a
sudo apt-get update