Q:

Reinstall package and its installed dependencies

I've got a package installed that is broken (the package itself, not its dependencies). Reinstalling it with sudo dpkg-reconfigure <package> or sudo apt-get --reinstall install <package> did not do the trick. I'd like to try and reinstall the package, including all its currently installed dependencies. Is there a way to do this?

A:

You can check all package dependencies with apt-cache:
$ sudo apt-cache depends <package>

Using the results of that command, we get the following one, which re-installs <package> and its dependencies:
$ sudo apt-cache depends <package> | grep '[ |]Depends: [^<]' | cut -d: -f2 | tr -d ' ' | xargs sudo apt-get --reinstall install -y

