-1

This question already has an answer here:

My question is NOT "how do I remove unused packages." The answers from other questions do not address my question explicitly

It's convenient that apt-get can find packages that are not in use and remove them to keep your system clean using sudo apt-get autoremove.

But what is its definition of "unused"?

  1. Not accessed for a long time
  2. Newer version also installed (but what if I need both Java 7 and Java 8?)

I'd like to use it to clean up my Ubuntu installation but if it's speculative in some way or risks breaking shared libraries I'd rather live in the filth of my server as is.

marked as duplicate by muru, George Udosen, Eric Carvalho, Charles Green, pomsky Dec 13 '17 at 16:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • A more direct answer to my question based on the contents of that would be great. – Sridhar-Sarnobat Dec 13 '17 at 0:18
  • Quoting Rinzwind's answer: "Whenever you install an application (using apt-get) the system will also install the software that this application depends on. It is common in Ubuntu/Linux that applications share the same libraries. When you remove the appplication the dependency will stay on your system. So apt-get autoremove will remove those dependencies that were installed with applications and that are no longer used by anything else on the system." Seems to me it answers this question, no matter how large you make your text. – muru Dec 13 '17 at 3:25
  • Please post as an answer and link to the original answer. Trying to read that with no formatting is virtually impossible (at least for me) – Sridhar-Sarnobat Dec 13 '17 at 3:37
  • It's the only answer to the dupe I linked to in my first comment. – muru Dec 13 '17 at 3:43
  • Still, posting as an answer (not a comment) would be easier to read – Sridhar-Sarnobat Dec 13 '17 at 3:44
3

A package will be marked as unused by apt if it meets two conditions:

  1. If it was automatically installed as a dependency as another

  2. No packages depend on it anymore

Excerpt from http://manpages.ubuntu.com/manpages/xenial/man8/apt.8.html:

autoremove (apt-get(8)) autoremove is used to remove packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed as dependencies changed or the package(s) needing them were removed in the meantime.

You should check that the list does not include applications you have grown to like even though they were once installed just as a dependency of another package. You can mark such a package as manually installed by using apt-mark(8). Packages which you have installed explicitly via install are also never proposed for automatic removal.

  • Does this answer your question @Sridhar-Sarnobat – user689314 Dec 13 '17 at 0:22
  • I think that's the info I was looking for. It won't tell me if some pointless CLI program I installed is in use or not. But it will find those shared libraries that I don't even realize are there, which is good. – Sridhar-Sarnobat Dec 13 '17 at 1:02
  • 1
    This is what apt uses – user689314 Dec 13 '17 at 2:10
  • 1
    I updated the question – user689314 Dec 13 '17 at 2:11
  • 1
    updated the answer – user689314 Dec 13 '17 at 2:17
2

For every installed package the package manager keeps a record of whether that package is marked "automatically installed" or not, among other metadata.

Packages installed during OS installation are never marked automatically installed.

When you install a package it may cause other packages you didn't request to be installed as well. Those additional packages will be marked as automatically installed.

This is only a convenience feature allowing you to remove cruft you probably don't need anymore. You do not have to take advantage of it, but if you do, you can remove any automatically installed packages that are no longer a dependency of a manually installed package with apt-get autoremove.

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