Skip to main content
Home
The Baheyeldin Dynasty
The journey for wisdom starts with knowledge
  • Home
  • About
  • Site Map
  • Contact

How Needrestart on Ubuntu Helps With Security

  1. Home

By Khalid on 2026/03/25 - 18:45, last updated 2026/03/25 - 19:05

When you upgrade a package on Linux Debian/Ubuntu, you need to restart any binaries that are running in order for bug fixes and security patches to take effect. Failure to do so, may leave programs open to exploits. The same applies to the Linux kernel itself.

The Ubuntu repositories have a neat application called needrestart that is very helpful in determining which programs need to be restarted after software updates. It also reports whether the kernel needs to be restarted, and several others things.

The manual page does not do the application justice.

There is a brief description on what it does on its Github repository, as well as a good page describing needrestart's behaviour.

Needrestart is automatically run after you run:

sudo apt full-upgrade

And some software is actually updated in that run.

In my case, I instruct needrestart to only list what needs to be restarted, rather than forcing a restart right now.
This lets me decide what can be restarted immediately, and what should be deferred based on the urgency of the change, and the specific machine's usage.
For example, if the machine is a busy web server, I would defer a restart of Nginx or MariaDB to the weekend.
Or if the server is used for business critical applications, the restart of said application, or reboot of the server, is deferred to late evening.

To make needrestart only list the changes, create a file in /etc/needrestart/conf.d/ and name it local.conf

# Change restart behaviour from (i) interactive, to (l) list
$nrconf{restart} = 'l';

Here are examples of the output, annotating each section.

This screenshot shows that I am running an old version of the kernel, and need to reboot.

It checks whether the microcode on the CPU needs to be updated:

The processor microcode seems to be up-to-date.

This is the most relevant part, listing all the services that need to be restarted:

Services to be restarted:
systemctl restart cron.service

It also lists services that need a restart, but cannot be restarted because they are in use:

Service restarts being deferred:
/etc/needrestart/restart.d/dbus.service
systemctl restart networkd-dispatcher.service
systemctl restart systemd-logind.service

It then lists user sessions that need a restart, but cannot be done right away either:

User sessions running outdated binaries:
johndoe @ session #10497: bash[683747], login[1065]
johndoe @ session #287184: bash[410827,410854,416071,416104,3391644,3391681,3852012], screen[3391639]
johndoe @ user manager service: systemd[1781]

It lists any containers that need to be restarted:

No containers need to be restarted.

It lists any virtual machine guests that are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.
Contents: 
Linux
Tags: 
Ubuntu
  • Add comment

Current

Talks

  • Presentations and Talks

Search

Site map

Contents

  • Family
    • Khalid
    • Ancestry
    • Extended
  • Friends
  • Nokat نكت
  • Writings
    • Cooking
    • Culture
    • Science
    • History
    • Linguistics
    • Media
    • Literature
    • Politics
    • Humor
    • Terrorism
    • Business
    • Philosophy
    • Religion
    • Children
  • Technology
    • Linux
    • Arabization
    • Drupal
      • Association
    • Software
    • Internet
    • Technology in Society
    • Digital Archeology
    • NCR History
    • MidEast Internet
    • Programming
    • Saudi ISPs
    • Miscellaneous
  • Places
    • Canada
      • Weather
    • Egypt
      • Cuisine
      • Alexandria
      • E.G.C.
    • USA
    • Saudi Arabia
  • Interests
    • Astronomy
    • Fishing
    • Photography
    • Snorkeling
    • Nature
    • Photomicroscopy
  • Miscellany

In Depth

  • al-Hakim bi Amr Allah: Fatimid Caliph of Egypt الحاكم بأمر الله
  • Alexandria, Egypt
  • Arabic on the Internet
  • Articles on the history of Muslims and Arabs in the Iberian Peninsula تاريخ المسلمين و العرب في الأند
  • DIY GOTO Telescope Controller With Autoguiding and Periodic Error Correction
  • E.G.C. English Girls College in Alexandria, Egypt
  • Egyptian Cuisine, Food and Recipes مأكولات مصرية
  • George Saliba: Seeking the Origins of Modern Science?
  • Internet Scams and Fraud
  • Mistaken for an Arab or Muslim: Absurdities of being a victim in the War on Terror
  • Mistaken Identity: How some people confuse my site for others
  • One People's Terrorist Is Another People's Freedom Fighter
  • Overview of Google's Technologies
  • Photomicroscopy
  • Pseudoscience: Lots of it around ...
  • Resources for using Google Adsense with Drupal
  • Rockwood Conservation Area, Southern Ontario
  • Selected Symbolic Novels And Movies
  • Snorkeling the Red Sea near Jeddah
  • Updates and Thoughts on the Egyptian Revolution of 2011

Recent Content

Most recent articles on the site.

  • How Needrestart on Ubuntu Helps With Security
  • How To Run A Script When Daylight Savings Change
  • Moon Sighting Is Obsolete: Lunar Month Starts Should Be By Astronomical Conjunction
  • Presentations and Talks
  • How To Suppress Excessive Logging by PAM
more

Most Comments

Most commented on articles ...

  • Another scam via Craigslist: offering more than asking price
  • Warning to female tourists thinking of marrying Egyptians
  • Craigslist classified for used car: Cheque fraud scam
  • Winning the lottery scam email: World Cup South African lottery
  • Email Scam: BMW 5 Series car and lottery winning
more

About Khalid

Various little bits of information ...

  • Khalid Baheyeldin: brief biography
  • Presentations and Talks
  • Youtube Videos
  • GitHub Projects
  • Drupal.org Profile
  • Astrophotography @ Flickr

Sponsored Links

Your Link Ad Here

Tags

419 Android App Arabic backup Balkanization Comet Conspiracy Coronavirus COVID-19 CPU DIY Ericsson Firefox GSM Home Assistant Kubuntu Laptop Mobile OnStep OpenWRT Python Rogers Router Scam Sony Spectrum tablet Telescope Ubuntu
More

© Copyright 1999-2026 The Baheyeldin Dynasty. All rights reserved.
You can use our content under the Terms of Use.
Please read our privacy policy before you post any information on this site.
All posted articles and comments are copyright by their owner, and reflect their own views and opinions, which may not necessarily be consistent with the views and opinions of the owners of The Baheyeldin Dynasty.

Web site developed by 2bits.com Inc.