36

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?

  • autoremove itself will only remove left over dependencies of packages you no longer have. If you uninstalled a main package (like Ubuntu desktop) autoremove might have gotten confused and removed other things it didn't think you needed anymore. I've used autoremove a lot and never had any problems. – Seth Dec 19 '13 at 21:24
  • 1
    Is there a way of checking if it's safe? Because I did have problems using it. – Nkciy84 Dec 19 '13 at 21:25
  • It will verify with you before it removes any packages. – Seth Dec 19 '13 at 21:31
  • No need to add a extra line between them ;). – Braiam Dec 19 '13 at 21:35
  • Lol @Braiam , I figured if you make it more readable, you were probably right to do so. Tried to make it even better :) – Nkciy84 Dec 19 '13 at 21:37
51

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.

  • Thank you, this was actually the answer I needed. Thanks for at least reading through the entire post before making assumptions due to the title and thinking tl;dr. The -s flag was the information I was looking for. – Nkciy84 Dec 20 '13 at 7:43
  • It's not safe! I just killed my ros installation because apt thought it would be a nice idea to autoremove it. No I cannot reinstall it because of unmet Dependencies and ` held broken packages` :(. What a mess!!!! – mcExchange Feb 25 '16 at 15:57
  • 2
    @mcExchange It will have warned and prompted you before it did any of that. Per the last line, it's only as safe as the person using it. – Oli Feb 25 '16 at 16:06
  • Yes I was warned / prompted then I read your answer and felt that it was safe doing it. However it's a semi catastrophe! I thought it's at least worth mentioning it. Ubuntu is extremely sensible when it comes to dependencies. Maybe it was the fault of the ros developpers but who cares. It's just miserable how easily one can fall into the dependency hell on a Ubuntu system – mcExchange Feb 25 '16 at 19:06
5

The following packages were automatically installed and are no longer required

If they are no longer required apt will know when it builds the dependencies. apt-get just inform you "Hey, you removed something that installed these packages. I prefer that you decide what to do with them since you are the boss".

Now, it is safe? Yes. What happen if you need em again? apt will download them. Should I check the list? Yes. A light check might be needed.

  • I'm sorry, but the confusing part for me is that one time where I used apt-get autoremove and it left me with only the CLI and no x-server. The pain this cost me to reinstall (read: time and effort) was just not funny anymore. – Nkciy84 Dec 19 '13 at 21:36
  • 1
    @Nkciy84 that was because you probably removed a meta-package. And didn't read the packages that you will uninstall. IMO, apt ask you if you remove a package that will leave the system crippled/unbootable so, only if you read that will remove some 100 packages you do not need to worry. – Braiam Dec 19 '13 at 21:40
  • it handily autoremoved ALL my network drivers. I'm pretty sure they were required! :( – JamesRyan Sep 10 '17 at 13:27
  • @JamesRyan you had the list of packages asking you for confirmation. Also, I'm pretty sure you didn't installed those package, since they were marked as automatically installed. – Braiam Sep 10 '17 at 13:32
  • @Braiam it didn't ask me for confirmation, and whether they were installed automatically is irrelevant when the PC has now been cut off and I have to faff around trying to fix it with usb sticks. My underlying problem was that ubuntu filled up the /boot partition. None of this is stuff a user should need to touch, it is plain bad user experience created by ubuntu. – JamesRyan Sep 10 '17 at 13:39
1

Unsafe example:

apt-get remove --purge icedove*

Never, almost never use an asterisk except for libreoffice

With great power comes great responsibility. Generally you should use the synaptic package manager which offers much better presentation (warnings**) then the terminal.

For example on debian Jessie (8.2) I noticed imagemagick was not functioning and that there were 2 shortcuts to it in the menu of a default install. I started with:

apt-get remove --purge imagemagick

That got rid of one shortcut, then I launched synaptic and two packages were left one of those being imagemagick-common. Upon selecting that package for complete removal it showed inkscape as the 1st thing that had to be removed as a consequence among many others.

Now do the same thing in the terminal, and it won't jump at you nearly as much. It might not phase you at all unless you're a linux veteran.

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.