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?
Asked
Active
Viewed 7.5k times
35
Forage
- 1,480
- 2
- 14
- 21
1 Answers
49
You can check all package dependencies with apt-cache:
apt-cache depends <package>
Using the results of that command, we get the following one, which re-installs <package> and its dependencies:
apt-cache depends <package> | grep '[ |]Depends: [^<]' | cut -d: -f2 | tr -d ' ' | xargs sudo apt-get --reinstall install -y
BeastOfCaerbannog
- 12,964
- 10
- 49
- 77
Sebastian Potasiak
- 748
- 8
- 12
-
12That's it! Thank you. I modified the grep argument from `'Depends'` to `'[ |]Depends: [^<]'` to exclude _PreDepends_ and alternative package (_Depends:
_) 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 -
4For 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 09:14
-
1Nice! I suggest removing the `-y`. It's kind of nice to get a chance to confirm what packages are to be reinstalled. – user1202136 Aug 24 '20 at 07:52
-
@user1202136 To see what packages are to be reinstalled, execute the command after replacing the part `xargs ..........` by just `cat` – Maarten Fokkinga Nov 01 '20 at 20:33