Ubuntu – Is it safe to use the command apt-get autoremove in this particular scenario


The last time I used sudo apt-get autoremove, nearly every important display driver or parts got deleted. This made me very squeamish about using the command again. However, each time I install something or use apt-get update the terminal reads:

The following packages were automatically installed and are no longer required:
  devilspie libturbojpeg:i386 libxrandr-ltsr2 language-pack-kde-en
  kde-l10n-engb language-pack-kde-en-base libxv1:i386 libllvm3.2
  libllvm3.2:i386 linux-generic-lts-raring
Use 'apt-get autoremove' to remove them.  

I tried the command clean and the messages stops displaying for a while. My question is whether it's safe running the autoremove command, or will I lose everything once again? Is there a way of checking how safe it is to use autoremove in this particular (or any) case?

Best Answer

To focus on your past experience, if autoremove is going to remove "more than you intended", it's only doing that because those packages are no longer depended upon. That happens when you accidentally remove something :)

A common example from the good old days would be removing something Compiz-related. apt-get would show you a list of Compiz packages it was going to remove and you'd miss that ubuntu-desktop was also in there. ubuntu-desktop is just a meta-package that depends on all the packages that make up the desktop so removing it doesn't directly remove anything...

... But when you do an subsequent autoremove, all those things that ubuntu-desktop was the sole dependency... They're going bye-bye.

A few lessons:

  • sudo apt-get remove <package> will warn you what it's going to remove directly. It won't notify you about knock-on effects.
  • sudo apt-get autoremove should also warn you what it's going to do.
  • Use apt-get -s autoremove to do a simulated dry run if you're unsure. You can use that on all apt-get commands.
  • If you reboot and you're staring at TTY1 wondering what the monkeys you've nuked this time, /var/log/apt/history.log should have you most recent activity.
  • If in doubt, check ubuntu-desktop is installed.

Is autoremove safe? It's heavy machinery so it's only as safe as the driver... But that said, it's hard to do permanent damage.

Related Question