Reinstall Ubuntu with one command

There is a very simple command that reinstalls all the distribution packages and reconfigures them automatically. This is particularly helpful when you have done a partial upgrade and eventually have broken the system dependencies tree.

sudo dpkg-reconfigure -phigh -a

since this command would take a lot of time to process (~1 hour) depending on your hardware in case you have a minor dependency problem you can fix it via

sudo apt-get install -f

Thanks to aldeby for this command.

sudo dpkg-reconfigure -phigh -a

As I watched, every single package was stopped, reconfigured, and restarted. This process took the better part of an hour and a half, since it was effectively the same as re-installing but using packages that already existed. It finally completed and dumped my back to a command line. I rebooted into recovery mode, selected “try to fix X”, rebooted, and, to my untter amazement, Ubuntu had repaired itself! I was restored to a completely functioning desktop with the upgrade installed!

My point, is, if something gets broken during an upgrade, it looks like there is not too much that this command cannot fix. So, before you give up and reinstall (like I was about to do), give it a shot! It might work for you, too.

  • tsakf

    Very useful for many people, added article to my library.

  • Jujubeeks

    This doesn’t work if you delete usr/lib, which is what I did :D

  • asd haha

    you are stupid if you deleted that folder -_-

  • Eskender Tamrat

    hey … cut us some slacks … Of course, no one intentionally delete the /usr directory, it’s just by some sort of accident or the “sudo rm -r” thing … (the second one in my case … :P) … So, calm down a bit.

  • Donald L. Beyer

    I can’t do anything cuz i deleted app store and alot of my factory enabled apps im really stupid when it comes to technology . I need someone to fix my problems please?