brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: /var/run/reboot-required tells you that an Ubuntu or Debian update needs a reboot

Linux
~/tips/tip-linux-var-run-reboot-required

ls /var/run/reboot-required && cat /var/run/reboot-required.pkgs

Check after updates whether a reboot is needed, and which packages asked for it.

After an update it is not always clear whether you need to reboot. On Ubuntu, and on Debian with the right package, the system tells you through a small file.

ls /var/run/reboot-required && cat /var/run/reboot-required.pkgs

When a package such as a new kernel or libc wants a reboot, its install hook writes *** System restart required *** into /var/run/reboot-required and appends its own name to reboot-required.pkgs. That is the line you see in the login banner. The second file is the useful one: it tells you which packages asked, such as libc6, or linux-base after a kernel update.

I’d put a one liner like this in scripts and monitoring:

[ -f /var/run/reboot-required ] && echo "reboot needed for: $(sort -u /var/run/reboot-required.pkgs | tr '\n' ' ')"

unattended-upgrades checks the same file when you enable its automatic reboot option. Because /var/run lives in memory, the files disappear at the next boot, so you never have to clean them up.

The file is written by the hooks from the update-notifier-common package, which Ubuntu installs by default. On a minimal Debian system without it, nothing writes the file and the check always says no. It also only covers packages that asked for it. A library update that leaves old copies in memory in running services does not create the file; for those, a tool like needrestart tells you which services to restart.

Further reading: update-notifier notify-reboot-required script, Ubuntu Server: automatic updates

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link