Linux Administrator

How to :- Exclude Packages from apt-get Upgrade Command in Ubuntu/Debian

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?

How to Exclude Packages from apt-get Update Command?

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

How to 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:)

Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.

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