Linux Administrator

Exclude Package From Apt-Get Upgrade In Ubuntu/Debian

exclude-package-from-apt-get-upgrade
mm
Written by Santosh Prasad

When we run the full update or automatic packages upgrade process on system, sometime accidentally we upgrades those packages which is not to update and this creates serious issue on the server. Recently I upgraded my one production server and accidentally I upgraded PHP version due to which some PHP function deprecated. Although I reverted my PHP version to overcome this issue.

In this tutorial I will describe how you can exclude packages from apt-get update command? How to prevent packages from auto update using apt command?

Exclude Package or Hold

Follow the below command to exclude or hold the specific Debian package from update.

Using Apt Command

$ sudo apt-mark hold package-name

Using Dpkg Command

$ echo "package-name hold" | sudo dpkg --set-selections

Using Aptitude

$ sudo aptitude hold package-name

Include Package or Unhold During Installation

If you want to upgrade any hold and exclude package, you can use the below command.

Using Apt Command

$ sudo apt-mark unhold package-name

Using Dpkg Command

$ echo "package-name install" | sudo dpkg --set-selections

Using Aptitude

$ sudo aptitude hold package-name

I hope this article will help you to exclude package from apt-get upgrade command. If you have any queries please comment in comment section.

Thanks:)

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment