Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

1 Answer 1

up vote 4 down vote accepted

You can check all package dependencies with apt-cache:

$ sudo apt-cache depends <pacakge>

I didn't checked command seqece below, but it should work and remove ALL <package> dependencies:

$ sudo apt-cache depends <package> | grep 'Depends' | cut -d: -f2 | tr -d ' ' | xargs -d "\n" sudo apt-get purge -y

Remember that you should check if the <package> doesn't require any important system packages, because this command seqence would remove them with all configuration.

If you want to keep configuration for packages, use remove instead of purge.

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

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.