Home Linux Community Community Blogs Distributions How-to: Blacklist Packages in Ubuntu

How-to: Blacklist Packages in Ubuntu


I don't know about everyone else, but the pushy nature of Ubuntu's auto-update mechanism drives me crazy. In particular the fact that continues to try to force grub2 to be installed. After much searching, asking around and experimenting I finally found how to properly blacklist packages or package sets in Ubuntu.



In my case I use Slackware Linux as my Primary OS in which I setup grub(legacy) as my primary bootloader, every time I went to update or upgrade ubuntu it tried to force grub2 to overwrite my MBR, this had to stop. I searched the net for answers with none found, I asking in irc channels with no success, so finally I decided to look around /etc/ at the configuration files for an option and I discovered it.


The answer is very simple:


  1. Remove the packages you don't want using apt-get, synaptic package manager or the software center.
  2. open apt's 01autoremove file by issuing the command sudo gedit /etc/apt/apt.conf.d/01autoremove
  3. Navigate to the bottom of the section titled Never-MarkAuto-Sections
  4. Add and entry to the section in my case to block grub I entered "grub*";.  The contents of the modified file is at the bottom of this page.
  5. You will enter the package name or portion of package names, including using * as a wildcard, in my case grub* blocks all packages that start with the word grub.


It is complete, when you next open the update utility it will not show the option to upgrade or update the software  that you chose to block.

The resolution is simple, but no documentation was found prior to this post. 

I hope you find this useful.


My /etc/apt/apt.conf.d/01autoremove file:


 NeverAutoRemove  {
  "^linux-image.*";   "^linux-restricted-modules.*";
 {   "metapackages";


Subscribe to Comments Feed

Upcoming Linux Foundation Courses

  1. LFS101 Introduction to Linux
    01 Jan » 31 Dec - Online Self-Paced
  2. LFS201 Essentials of System Administration
    01 Jan » 31 Dec - Online Self-Paced
  3. LFS201-Esp Fundamentos de Administración de Sistemas Linux
    01 Jan » 31 Aug - Online Self-Paced

View All Upcoming Courses

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board