I need to use

sudo apt-get -y --purge remove $manypackages

where $manypackages includes dependencies of a package that I don't want removed.

Is it possible to prevent apt-get from removing those dependencies instead of me having to determine them and remove them from the $manypackages list beforehand?


There is no way to prevent explicitly removing packages, which is what the command you want to issue will do. A workaround is to mark the packages as auto, then let apt autoremove the ones that are no longer needed.

sudo apt-mark auto $many_packages
sudo apt-mark manual $keep_packages
sudo apt autoremove

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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