Free software is one of the best inventions that exists, since it allows anyone who knows how to program, to change the code as they wish 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 fix broken or misinstalled packages in Ubuntu from terminal.
And it is that learning this is of vital importance 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. Gaining knowledge on this topic will change your perception about free software and you will see how great it is to use it, plus you will be able to install packages or programs more safely next time.
How to fix broken or misinstalled packages in Ubuntu from terminal?
Now, with that in mind, the time has come for you to learn how to repair broken packages so that you can use them as you like when 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 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 place the following command in the terminal: sudo dpkg –configure –a, this will bring up the configuration for you to correct.
If everything was fine, then it is a broken package and not a configuration problem, so now you must use the command: sudo apt clean, this will clean the package and install a script in the /var/ path. cache/apt/archives/.
With that you should be able to repair broken or badly installed packages in Ubuntu from terminal, in case it does not work, continue with the following commands:
Fix broken or misinstalled packages with sudo apt autoclean and sudo apt autoremove
The first of these is used to clean the deb-type packages that are already obsolete and the second eliminates the packages that have been left as orphans which no longer need the system (if you add –purge to this last command, it will purge the packages).
sudo dpkg –purge –force-remove-reinstreq ssh
You should apply this if none of the above has worked and you also try to uninstall the package to try another one and it doesn’t let 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 now repair broken or incorrectly installed packages in Ubuntu from terminal, use sudo apt update && sudo apt upgrade, to update your system and everything is in order.
And that’s it, your problem should be solved, so now 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 the 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 manage this program.