1. Is it possible to do

    sudo apt-get autoremove

without removing packages in use?

I did an autoremove command and it asked my if i wanted to remove those packages. Since it was a lot of packages i didn't specificly check everyone. Together it was 163mb. After this removal i saw my desktop icons change. I didn't want that to happen since i was using those icons.

I restored those packages from the log file thanks to these commades

echo '#!/bin/bash' > restore
echo sudo apt-get install `grep Remove /var/log/apt/history.log | tail -1 | sed -e 's|Remove: ||g' -e 's|([^)]*)||g' -e 's|:[^ ]* ||g' -e 's|,||g'` >> restore
chmod +x restore 

Thanks to https://serverfault.com/questions/380856/how-to-undo-apt-get-remove

  1. Are there any reason for it to do that or in a different way what are the properties of autoremove?
  2. Is there a way to chose which packages autoremove does not remove?

Thanks to all responses in advance


Mark the packages as manually installed:

sudo apt-mark manual <package_name>

From man apt-mark

    manual is used to mark a package as being manually installed, which
    will prevent the package from being automatically removed if no
    other packages depend on it.

After the start of your restore all the packages have been set to the status "manually", which were installed by restore.

  • After OP re-installed them, they are already manual. – Pilot6 Jun 9 '15 at 20:11
  • @Pilot6 I know. But that was not the question. Anyway, I will add this fact. Thank you. :) – A.B. Jun 9 '15 at 20:19
  • I guess that would be the option i would have to use on 20 lines of packages :-| – Jean Jun 9 '15 at 22:16

Autoremove does not remove packages that can/should be used in the system.

It removes only orphan packages that had been installed by dependencies of other packages that previously had been removed.

So you can safely run this command and agree to remove everything it suggests.

In your case you probably removed some master package that pulled some other useful packages.

If you re-install them again, they will never be affected by autoremove.

  • true but i don't want to go over about 20 lines of packages to find the ones that i will reinstall :) – Jean Jun 9 '15 at 20:09
  • General advice is not to remove anything if you are not sure. Or never run autoremove. I do not think there is another way. – Pilot6 Jun 9 '15 at 20:10

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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