I want to remove the recommended packages of a package using apt
.
my-package
is installed, and I want to keep it and its dependencies.
apt-cache depends <my-package> | grep Recommends
returns a variety of packages, none of which I want.
How can I remove these packages? I can write a bash script to do it but I'm hoping there's an apt
way to do it.
I have searched online and haven't found a way to uninstall these recommended packages without uninstalling the package itself and its required dependencies. In other words, I want to keep my-package
and its dependencies, but remove the packages it recommends.
Furthermore I ideally don't want to edit config files; I want to keep the system settings untouched.
apt-cache
andgrep
like you have, then use the mouse to copy-paste the unwanted package names to anapt-get purge
command line. It's just not something I do often enough to be worth the bother of learning a single-use specialised tool. If you want to get fancy, you can usesed
,awk
, orperl
instead ofgrep
to get rid of the commas and version numbers and alternations.apt
's-d
(--download-only
) option as a dry-run so you don't accidentally uninstall stuff you didn't mean to.--autoremove
and then install it with--no-install-recommends
. If youremove
rather thanpurge
, you shouldn’t lose anything, other than downtime if any of the removed-and-reinstalled packages provide services. This would also avoid the explicit removal of packages and the consequences mentioned by cas above.