Free software is one of the best inventions that exists, since it allows anyone who knows how to program, change the code as they want to create new functions and thus improve the operating system with which they are working. With this in mind, today you will learn how to repair broken or badly installed packages in Ubuntu from terminal.
And it is that learning this is vitally important for anyone who wants to learn to use a terminal fully and also for anyone who needs of course to repair a file that has been broken. Obtaining knowledge on this subject will change your perception of free software and you will see how great it is to use it, also you will be able to install packages or programs with greater security the next time.
What is a package?
The first thing you should know to get straight to the point is that the need to repair a package is that, if there is a broken one, the installation of it is not finished, so you will not be able to use its functions in any way.
For you to understand it better and before you learn to repair broken or badly installed packages in Ubuntu from terminal, you have to know what is a package?
These are basically sets of files that contain information about a program or application, as well as configuration files, executables, among others. All of these come to life within the so-called package.
A broken package is called a package that has not been installed correctly, either due to an interruption or an improper modification within it. This causes (as you have read before), that the package cannot be used correctly or that it will not even be there at all.
How to repair broken or badly installed packages in Ubuntu from terminal?
Now, taking that into account, it is time for you to learn to repair broken packages so that you can use them as you like by installing them properly. For this you have to use commands from the Ubuntu terminal, so the first step is to open it.
When you have it open you must place the corresponding commands that will help to fulfill the task, of these there are many giving you different ways to repair the packages, the first would be:
Checking if there is a configuration problem, to achieve this you must put the following command in the terminal: sudo dpkg –configure –a, this will make the configuration appear for you to correct it.
If everything was fine, then if it is a broken package and not a configuration problem, so you must now use the command: sudo apt clean, this will clean the package and install a script in the path / var / cache / apt / archives /.
With that you should be able to repair the broken or badly installed packages in Ubuntu from the terminal, in which case it does not work, continue with the following commands:
Repair broken or improperly installed packages with sudo apt autoclean and sudo apt autoremove
The first of these serves to clean the deb packages that are already obsolete and the second removes the packages that have been orphaned which are no longer needed from the system (if you add –purge to this last command, it will purge the packages).
Sudo dpkg – purge – force-remove-reinstreq ssh
This should be applied if none of the above has worked and you also try to uninstall the package to try another one and it does not leave you either. Basically what it does is force all the data of the program in question to be deleted.
Finally, once you have tried each of the previous commands and you can repair the broken or badly installed packages in Ubuntu from the terminal, use sudo apt update && sudo apt upgrade, to update your system and that everything is in order.
And you’re done with this, your problem should be solved, so you can go to your PC and start repairing all those packages that you thought were dead. And when you finish remember to look for more information about Linux and Ubuntu such as: how to list all installed Ubuntu packages , enable the root user in Ubuntu , or how to uninstall a program or application from the terminal so that you learn to better handle this program.