Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a bunch of shared libs installed on my system which aren't dependencies of some concrete package but are needed for non-apt-managed libraries I've built from source (like latest SDL, Allegro, SFML, ...) and other software built from source. The problem is that those libraries are seen by APT as unused, and are therefore candidates for auto-removal, and those get mixed up with legitimate unused packages that are free to remove.

Is there a way to mark packages as used so that they are not suggested for auto-removal? My first thought was to build my own metapackage just to hold the dependencies (like for example ubuntu-desktop is), but I don't know how to do that.

share|improve this question
up vote 9 down vote accepted

Although apt-get install marks packages as installed too, it does other things like upgrading packages (if there is an upgrade available). The correct program to change the automatically-installed states is apt-mark.


Marking a package as manually installed (such that it won't be removed by apt-get autoremove):

sudo apt-mark manual package1 package2 ... packageN

To mark a package as automatically installed (such that it will be removed by apt-get autoremove if no packages depend on it):

sudo apt-mark auto package1 package2 ... packageN

More details are available in the manual page apt-mark(8).

share|improve this answer

Just use apt-get install:

sudo apt-get install [your-packages]

It won't actually install them. It will just set the flag to manually installed.

share|improve this answer

You don't have to do anything so complicated as creating your own metapackages.

Suppose you want to make sure a package called foo is never eligible for autoremoval.

Open a Terminal window (Ctrl+Alt+T) and run:

sudo apt-get install foo

That is, the same command that installs packages manually will mark them as manually installed so they will not be autoremoved even when the packages for which they were originally installed as dependencies are themselves removed.

share|improve this answer
@BorisB. If you manually installed a package, then no matter how you did that, so long as it was not subsequently removed or marked as automatically installed, it will not be autoremoved. – Eliah Kagan Jun 12 '12 at 9:11
You must have installed them as a dependency to something else. You probably did apt-get install yyy and xxx installed as a dependency. Then you removed yyy and xxx was marked for autoremoval. Now you do apt-get install xxx. – Vitalie Ciubotaru Jun 12 '12 at 9:12
I'm 99% sure I did install those libraries using apt-get install (since I know of no other way of installing them), but they are still offered for auto-removal. – Boris B. Jun 12 '12 at 9:13
@VitalieCiubotaru Yes, that must be it. Thank you. – Boris B. Jun 12 '12 at 9:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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