If you have the reboot-notifier or update-notifier-common packages installed, then you get the files /var/run/reboot-required and /var/run/reboot-required.pkgs
reboot-notifier is newer in Ubuntu Wily and Xenial. Debian stretch, but in jessie-backports
update-notifier-common Is older, in all Ubuntu versions including Xenial and Debian Wheezy. Not in Debian Stretch or Jessie.
( There is some background to the reboot-notifier package at https://feeding.cloud.geek.nz/posts/introducing-reboot-notifier/ )
If you don't have these packages installed then you can compare the version of the linux package installed, with the version running:
tim@tramp:~$ dpkg -l linux-image-*
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
ii linux-image-3.16.0-4-amd64 3.16.7-ckt20-1+deb8u4 amd64 Linux 3.16 for 64-bit PCs
ii linux-image-amd64 3.16+63 amd64 Linux for 64-bit PCs (meta-package)
tim@tramp:~$ more /proc/version
Linux version 3.16.0-4-amd64 (firstname.lastname@example.org) (gcc version 4.8.4 (Debian 4.8.4-1) ) #1 SMP Debian <b>3.16.7-ckt20-1+deb8u3</b> (2016-01-17)
You can see here that the latest installed kernel is 3.16.7-ckt20-1+deb8u4 but the kernel running is 3.16.7-ckt20-1+deb8u3. So this system needs a reboot. The u4 vs u3 right at the end.
You might need to scroll the box above. In the /proc/version, it is the version near the end of the line that matters.
The very minor version code change is typical of a Debian security kernel update.
Another option is to install the
sudo apt-get install needrestart
sudo needrestart -k
Seems to work even if needrestart was installed after the kernel was upgraded.