Successfully tested on Ubuntu Server 12.04 LTS 64-bit

Doing frequent updates of your favorite OS and programs is always recommended. Not only does it allow you to take advantage of new features but it also minimizes the security risks by correcting the possible flaws spotted since the installation or the previous update.

In Ubuntu, software updates can be either automatic (see Automatic Updates in the official documentation for details) or… manual. If you choose to go the manual way, you’ll have to make sure to do the updates by yourself on a regular basis (Ubuntu’s welcome screen advises you of updates availability) using two commands:

sudo apt-get update

first, to re-synchronize the package index files from their sources (the repositories are listed in /etc/apt/sources.list), followed by:

sudo apt-get upgrade

to finally install the newest versions of all packages currently installed on the system.

This full update in one shot is very handy of course, but what to do if you don’t want to update a specific package? For instance, let say you patched and rebuilt a program for whatever reason and you don’t want it to be replaced by the new latest official version. What to do? This is where today’s useful command comes in:

sudo apt-mark hold package_name

Now, this package will never be updated automatically as well as manually as long as it is on “hold” status. To display this status, you can use:

dpkg --get-selections | grep "package_name"

Finally, the day you decide to allow the upgrade to the latest version available in the official repository, just type:

sudo apt-mark unhold package_name

to put the package back on “install” status.

That’s all Folks!

For further reading, take a look at Package Management in Ubuntu’s official documentation.