Thursday 5 April 2018

How to fix broken packages in Ubuntu

If you are a curious guy installing different applications, trying them and removing the one not needed, you must have faced broken packages issue at some point of time. This could be because of various reasons and can to some extent hamper your system's performance. 

Broken packages can make a mess of your system. There could be some dependency missing, or while uninstalling, some part of the application is not removed completely and not allowing a reinstall. 

However, you can easily fix it with a couple of commands. In this article, we will see how to fix broken packages in Ubuntu. 

When you know the package name 

If you know the package name, you can completely remove it with the below command.

sudo dpkg --remove --force-remove-reinstreq <package-name>

Removing the unwanted dependencies

Along with the packages, the dependencies are also installed. However, you remove the application, the dependencies are left as it is. Using the below command, you can remove these unwanted dependencies.

sudo apt-get autoremove

Fix broken packages 

If there are some packages that were automatically installed and are not needed, or there's some broken packages because of some missing components, you can fix it by using the below command, 

sudo apt-get --fix-broken install 

Removing local repository which are no longer needed

You can remove the local repository of the retrieved package files with the below command:

sudo apt-get clean
sudo apt-get autoclean

autoclean deletes the local repository of the retrieved files that can no longer be downloaded and are mostly useless.

The below command removes any packages that are not updated and no longer needed along with the configuration files it needs. 

sudo apt-get --purge remove

Update your system

Chances are that one of the above command will fix broken packages in Ubuntu. Once done, do not forget to update your system.

sudo apt-get update

Do you have any other suggestions to fix broken packages in Ubuntu? Let us know in the comments. 


Post a Comment