Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 15 down vote accepted

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
share|improve this answer
6  
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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