21

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?

26

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
  • 10
    That's it! Thank you. I modified the grep argument from 'Depends' to '[ |]Depends: [^<]' to exclude PreDepends and alternative package (Depends: <package>) entries. The apt-get arguments would need to be --reinstall install to do the actual reinstalling I was after. – Forage Mar 30 '13 at 15:05
  • 1
    For that you have not tested it, it's pretty brave to post it without further explanation. After all you delete a few packages. – A.B. Mar 25 '15 at 9:14

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.