/var/run/reboot-required —(updated)

In Linux, key components like the kernel and libraries remain active in memory during operation. After updates, rebooting is essential to ensure processes use the latest versions. Without a reboot, outdated components can cause instability, security risks, and performance issues.

/var/run/reboot-required —(updated)
Image credit: Unknown. Please contact us if you are the owner.



On Debian-based distributions such as Debian, Ubuntu, and Linux Mint, the file /var/run/reboot-required is used to indicate that the system should be rebooted after installing certain updates.

The file is typically created automatically by package post-installation scripts when an update affects components that cannot be fully replaced or activated until the system is restarted. Common examples include a new Linux kernel or critical system libraries, such as glibc, which provides the essential Application Programming Interfaces (APIs) that applications rely on to interact with the Linux operating system.

How to Know When a Reboot Is Required

After installing system updates with apt, you can check for /var/run/reboot-required to quickly determine whether the system needs to be restarted:

$ [ -f /var/run/reboot-required ] && echo "Reboot required"

If the file exists, the command outputs:
Reboot required

Otherwise, it produces no output.

Breaking Down the Command Line

Let's take a closer look at what each part of this command-line (CLI) instruction does:


a. [: This is a synonym for the test command in shell scripting. It checks the condition specified inside the brackets.
-f /var/run/reboot-required: This is the condition being tested.

b. -f: This flag checks if the specified path refers to a regular file.

c. /var/run/reboot-required: This is the path being checked. If this file exists and is a regular file, the condition returns true.

d. &&: This is a logical AND operator. It allows you to execute the command that follows it only if the preceding command (the test in this case) is true.

e. echo "Reboot required": If the condition is true (meaning the file exists), this command will execute, outputting the text "Reboot required" to the terminal.

Use cat to Display the Reboot Message

You can use the cat command to display the contents of /var/run/reboot-required:

$ cat /var/run/reboot-required

When a reboot is required, the file will typically contain a message similar to:

*** System restart required ***

This provides a quick confirmation that the system has flagged a pending reboot.


BONUS

Here’s a little useful script you can keep on your system to quickly check whether a reboot is required.

Create a file named:
reboot-check.sh

Add the following:

#!/bin/zsh

# ============================================================
# Reboot Check
# ============================================================

if [[ -f /var/run/reboot-required ]]; then
    echo "🤖⚡️ 👉 yes"
else
    echo "🫡🦿 👉 no"
fi

Once you've saved the script, install it as a system-wide command:

$ sudo install -m 755 reboot-check.sh /usr/local/bin/reboot-check

The install command copies the script to /usr/local/bin/ and sets its permissions to 755, making it executable.

You can then run it from anywhere with:

$ reboot-check

For example:

🤖⚡️ 👉 yes

or

🫡🦿 👉 no

A tiny script, but a convenient way to check whether your Debian-based system is waiting for a reboot.



After you reboot the system, the /var/run/reboot-required file is automatically removed.
There is no need to delete it manually—the system handles the cleanup as part of the reboot process.

For system administrators, checking for the presence of this file after running updates is a simple way to determine whether a reboot is pending, particularly after kernel or core system library updates.
Rebooting ensures that the newly installed components are fully loaded and that all changes take effect.


We hope you found these tips useful!
It’s a simple check, but one that can make Linux system administration a little easier and help ensure your updates are fully applied.

Keep Us Caffeinated  ⦿ ⦿
Spotify Logo
SNUBmonkey Join our readers 37K+