From http://www.kabatology.com
sudo dpkg-reconfigure -phigh -a
This simple command can reinstall all of Ubuntu’s distribution packages and reconfigure them. If you ever find it necessary to reinstall Ubuntu, first backup your data then drop this line of code unto the command-line.
It takes about an hour for the whole process to get to an end, but that also depends on your hardware – with modern PCs it takes less time. If you run into minor dependency issues then use the renowned
sudo apt-get install -f
to fix it.