Score:4

How does apt-get autoremove work when given a package as an argument?

us flag

I recently logged onto a shared server to see why I couldn't access a samba share. I tried to open smb.conf with vim and found out that vim wasn't installed anymore. I found out that my Samba share was inaccessible because samba was also no longer installed.

I looked in apt's logs and saw the timestamp by when Samba was removed and looked in auth.log and found this line right around that time:

COMMAND=/usr/bin/apt-get autoremove libpython3.8-stdlib

Every example I can find of apt/apt-get autoremove shows it invoked with no argument. What happens when you give it a package? Does this explicitly remove that package and all its cascading dependencies? This is the only explanation I can think of that would explain why samba and vim would be uninstalled.

Score:7
vn flag

You are (almost) correct in your assumption. Running apt-get autoremove <package> will first remove <package>, and then autoremove as if you had run apt-get autoremove with no parameters (i.e. removing all "automatically installed" packages that are not a dependency of any "manually installed" packages).

The important distinction here is that the autoremove part of running apt-get autoremove <package> will remove not only packages that are a dependency of <package>, but all packages that would otherwise be autoremoved.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.