Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
Welcome to Ask Ubuntu! @user275109: If someone's answer was helpful to you, then please consider marking it as the accepted answer so others may more easily find it in the future. This is also a polite way to thank the person answering your question for helping you out. –  Danatela Apr 28 at 4:34

2 Answers 2

  • 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.

share|improve this answer
1  
Wouldn't an explicitly install on B do the same? Or is a --reinstall needed? –  Rmano Apr 27 at 23:05
    
@Rmano, sudo apt-get install some-package would work, yes. –  DaboRoss Apr 28 at 3:42

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]
share|improve this answer

Your Answer

 
discard

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.