# \`needs-restarting\` vs \`checkrestart\`: Managing Service Restarts After Updates in Linux

**URL:** <https://minica.tech/t/needs-restarting-vs-checkrestart-managing-service-restarts-after-updates-in-linux/202>\
**Category:** Tools for Self-Hosting\
**Tags:** needs-restarting, checkrestart\
**Created:** [September 27, 2024, 8:36am UTC](https://minica.tech/t/needs-restarting-vs-checkrestart-managing-service-restarts-after-updates-in-linux/202 "2024-09-27T08:36:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vasile.Minica](https://minica.tech/user_avatar/minica.tech/vasile.minica/32/3_2.png) [@Vasile.Minica](https://minica.tech/u/Vasile.Minica)\
**Post date:** [September 27, 2024, 8:36am UTC](https://minica.tech/t/needs-restarting-vs-checkrestart-managing-service-restarts-after-updates-in-linux/202/1 "2024-09-27T08:36:22Z")

</div>

#### Introduction

Regular updates are essential for maintaining the security and performance of Linux servers. However, after applying updates, you often need to restart services or even the whole system to ensure changes take effect. Two commands commonly used for this purpose are `needs-restarting` and `checkrestart`. But these tools serve different distributions and have distinct installation methods. In this article, we’ll explore what they are, how to install them, and when to use each.

#### What is `needs-restarting`?

`needs-restarting` is a command available in Red Hat-based Linux distributions, such as CentOS, Fedora, and Rocky Linux. It is part of the `yum-utils` package and is used to identify services or processes that need to be restarted after updates. This tool is particularly useful in production environments where minimizing downtime is a priority.

##### Installing `needs-restarting`

`needs-restarting` is included in the `yum-utils` package. To install it, use the following command:

For CentOS, Rocky Linux, or any other RHEL-based distribution:

```bash
sudo yum install yum-utils

```

Or for Fedora:

```bash
sudo dnf install yum-utils

```

##### Using `needs-restarting`

Once installed, you can run the command to see which services need restarting:

```bash
sudo needs-restarting

```

If it lists running processes, these services should be restarted for changes to take effect. To restart services or processes listed, you can either restart them individually or consider rebooting the system if many critical services are affected.

#### What is `checkrestart`?

`checkrestart` is the equivalent tool for Debian-based distributions, such as Ubuntu and Debian itself. This command is part of the `debian-goodies` package. It scans the system for services that are still using outdated files after an update and informs you which services need restarting.

##### Installing `checkrestart`

To use `checkrestart` on Ubuntu or Debian, you need to install the `debian-goodies` package. Here’s how to do it:

```bash
sudo apt update
sudo apt install debian-goodies

```

##### Using `checkrestart`

After installation, run the following command to identify services that need restarting:

```bash
sudo checkrestart

```

This command will output a list of services using outdated files that should be restarted. It’s an invaluable tool for post-update maintenance, ensuring your system operates with the latest software versions.

#### Comparing `needs-restarting` and `checkrestart`

| Feature | `needs-restarting` | `checkrestart` |
| --- | --- | --- |
| Available On | RHEL-based (CentOS, Rocky Linux, Fedora) | Debian-based (Ubuntu, Debian) |
| Installation Command | `sudo yum install yum-utils` | `sudo apt install debian-goodies` |
| Basic Usage | `sudo needs-restarting` | `sudo checkrestart` |
| Main Functionality | Lists services needing a restart | Lists services needing a restart |

#### When to Use These Tools

Both `needs-restarting` and `checkrestart` are primarily used after system updates. They help identify which services need to be restarted to apply new changes. These tools are especially important in environments where uptime is critical, as they allow administrators to selectively restart services instead of rebooting the entire system.

#### Do You Always Need a Reboot?

Not every update requires a full system reboot. For example, updating user-space applications like web servers (e.g., Apache, Nginx) usually requires only a service restart. However, kernel updates or changes to core libraries (like `glibc`) often necessitate a reboot.

To check if a reboot is required on Ubuntu or Debian systems:

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

```

For RHEL-based systems, running `needs-restarting` with the `-r` flag will check if a system reboot is necessary:

```bash
sudo needs-restarting -r

```

#### Conclusion

Knowing when to restart services or reboot your system after updates is crucial for maintaining a secure and stable Linux environment. `needs-restarting` (for RHEL-based systems) and `checkrestart` (for Debian-based systems) are valuable tools for identifying services that need restarting. By using these tools, you can ensure that your system is running the latest software versions without unnecessary downtime.
