Aptitude Tip: markauto and unmarkauto

Aptitude is great for package management at the command line. It is even smart enough to automatically remove packages that were installed as dependencies and are no longer needed on the system. When you install a package with aptitude, it is marked as manually installed, i.e. not automatically installed. On the other hand, if a package is installed because some other package depends on it, it is marked as automatically installed.

So far so good, but this can turn into a problem from time to time. Let’s say you’ve installed ubuntu-desktop, for example. Among other things, it automatically installed xsane, a program for scanning. Let us further presume that you liked xsane, but wish to remove ubuntu-desktop. The following command will also remove xsane, which is not what you want:

sudo aptitude remove ubuntu-desktop

That is what the markauto and unmarkauto aptitude commands are for. xsane is currently marked auto, because it was installed as a dependency of ubuntu-desktop. Aptitude tries to remove is because no other package depends on it. The solution is using

sudo aptitude unmarkauto xsane
sudo aptitude remove ubuntu-desktop

The markauto command works the other way around. It marks packages not manually installed, so they will be removed once nothing depends on them.

6 Responses to Aptitude Tip: markauto and unmarkauto

  1. Based on aptitude handling this type of thing I have long started using aptitude for package management vs apt-get. You could run debfoster but that is just a pain :)

  2. mertin says:

    can I do this for the inverse reason? I mean, I have gnome but really want to get rid of evolution, rhythmbox, games, printer, xsane, and some other apps.
    So if I do an aptitude unmarkauto on them, then I can remove *those apps* and keep my gnome. Right?

  3. Constantin says:

    Hmm, I’m not sure about that. There’s usually some kind of meta-package like ubuntu-desktop that depends on all those desktop apps, and removing that can potentially make upgrades more difficult. I suggest you ask on a forum or mailing list of your distribution, since I don’t know the answer to that.

  4. […] почитать документацию про ключ unmarkauto или глянуть сюда. 14. Как узнать что попало в файловую систему мимо […]

  5. Bachsau says:

    You can also use apt-mark or just apt-get install on a automatically installed package to set it manual.

  6. […] 13. Как удалить метапакет, но оставить одну из зависимостей? придётся почитать документацию про ключ unmarkauto или глянуть сюда. […]

%d bloggers like this: