Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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 9 down vote accepted

You can check all package dependencies with apt-cache:

$ sudo apt-cache depends <pacakge>

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

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

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

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

share|improve this answer
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
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 at 9:14

Your Answer


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.