Free software is one of the best inventions that exists, as it allows anyone who knows how to program, modify the code to their liking to create new functions and thus improve the operating system they are working with. With that in mind, today you will learn how repair broken or badly installed packages on Ubuntu from the terminal.
And it is that learning this is vital for anyone who wants to learn how to fully use a terminal and also for anyone who needs, of course, to repair a file that has been broken. Gaining knowledge on this topic will change your perception of free software and you will see how good it is to use it, plus you will be able to install packages or programs with greater security next time.
What is a package?
The first thing you should know to get right 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.
To understand this better and before learning how to fix broken or badly installed packages in Ubuntu from the terminal, you need 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 damaged package is called a package that was not installed correctly, due to an interruption or improper modification within it. This causes (as you read earlier) that the package cannot be used correctly or that it won't even be there.
How to fix broken or badly installed packages in Ubuntu from terminal?
Now, with that in mind, it is time for you to learn how to repair damaged packages so that you can use them however you like by installing them correctly. 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 need to enter the corresponding commands which will help you do the task, of these there are many which give you different ways to repair packages, the first would be:
Checking if there is a configuration problem, to achieve this you need to enter the following command in the terminal: sudo dpkg –configure –a, this will bring up the configuration to correct it.
If all went well then if it is a damaged package and not a configuration problem then now you have to 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 broken or badly installed packages in Ubuntu from the terminal, in which case it doesn't work, continue with the following commands:
Repair broken or incorrectly installed packages with sudo apt autoclean and sudo apt autoremove
The first of these is for cleaning deb packages that are already obsolete and the second removes packages that have been orphaned which are no longer needed by the system (if you add –purge to this latter command, it will delete the packages).
Sudo dpkg – purge – force-remove-reinstreq ssh
This should apply if none of the above worked and you also try uninstalling the package to try another one and it won't let you either. Basically what it does is force la cancellation of all the data of the program in question.
Finally, once you have tried each of the above commands and can repair 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 are done with this, your problem should be fixed, then you can go to your PC and start repairing all those packages that you thought were dead. And when you are done remember to look for more information on 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 can learn how to better manage this. program.