When to Restart Services or Reboot after Update on Debian or Ubuntu

After update Debian (or Ubuntu) using

apt-get update && apt-get -V upgrade

you need to know which services need restart and if system reboot is required (kernel upgrade).

A common workaround was to use checkrestart (which included in debian-goodies package) and /usr/lib/update-notifier/update-motd-reboot-required (which included in update-notifier-common package).

The package needrestart

Since Debian Jessie (and latest Ubuntu versions of course), the package needrestart will do all the job nice and easy:

Setup needrestart

apt-get install needrestart

needrestart will run automatically after each upgrade (apt-get update && apt-get -V upgrade) and will inform you with a friendly interface for each situation:

In case some services need restart

needrestart will display services need restart and prompt you to enter your choice:

Services need restart

In case system reboot required

needrestart will inform you that system must be rebooted (in order to use the new kernel):

Reboot required

In case restart is not needed

After scanning processes and kernel images, needrestart will inform you that “No services need to be restarted” (everything OK)

Restart is not needed

Run it independently

Of course, you can call it anytime you want to check your system: