11

Say I install package A, which depends on package B. Then I remove A.

Now apt-get autoremove wants to remove B, but I want to keep it. How do I "pin down" B so that the system acts as if I installed B myself?

I come from Gentoo, where the solution would be to add B to my world file. What's the Debian/Ubuntu equivalent?

0

2 Answers 2

10
  • You can use

    sudo apt-mark manual some_package
    

    to mark some_package as manually installed so that it doesn't get autoremoved.

  • You can use

    sudo apt-mark auto some_package
    

    to mark some-package as automatically installed so that it gets autoremoved.

2
  • 2
    Wouldn't an explicitly install on B do the same? Or is a --reinstall needed?
    – Rmano
    Apr 27, 2014 at 23:05
  • 1
    @Rmano, sudo apt-get install some-package would work, yes.
    – daboross
    Apr 28, 2014 at 3:42
0

You can also hold a package, so it won't get auto-removed while running sudo apt-get autoremove command.

sudo apt-mark hold <package-name>

To unhold the holded package,

sudo apt-mark unhold <package-name>

Example:

$ sudo apt-get -s autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  apache2-bin apache2-data libapr1 libaprutil1 libaprutil1-dbd-sqlite3
  libaprutil1-ldap
0 upgraded, 0 newly installed, 6 to remove and 13 not upgraded.
Remv apache2-bin [2.4.7-1ubuntu4]
Remv apache2-data [2.4.7-1ubuntu4]
Remv libaprutil1-ldap [1.5.3-1]
Remv libaprutil1-dbd-sqlite3 [1.5.3-1]
Remv libaprutil1 [1.5.3-1]
Remv libapr1 [1.5.0-1]

$ sudo apt-mark hold apache2-bin
apache2-bin set on hold.

$ sudo apt-get -s autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  apache2-data
0 upgraded, 0 newly installed, 1 to remove and 13 not upgraded.
Remv apache2-data [2.4.7-1ubuntu4]

Not the answer you're looking for? Browse other questions tagged .