Library / Linux

LINUX-001 · Script

Update Linux Packages

Lists pending package updates and, in apply mode, installs them with apt (Debian, Ubuntu) or dnf/yum (RHEL, Rocky, Alma, Fedora). Reports whether a reboot is required and can schedule one.

Version 1.0.0Language bashUpdated November 2026

What it does

Report mode does not install anything. With --refresh=yes it refreshes the package lists (apt-get update or dnf metadata), which is the same thing the system does on its own schedule. Apply mode keeps existing configuration files when a package offers a new one. Apply does not remove packages and does not perform a major release upgrade.

Requirements

Debian, Ubuntu, RHEL, Rocky, Alma or Fedora (apt-get, dnf or yum). Run as root. No prompts.

How to run it

  • Run from: an admin workstation or scheduled task with the Microsoft modules installed and app sign-in configured
  • This is an admin script for your Linux tenant, not a per-device endpoint script
  • User interaction: none with app-only sign-in
  • Schedule: run on demand, or weekly for reports

Settings

NameWhat it doesOptionsDefault
modedefault reportreport, applyreport
rebootdefault never; if-required schedules a reboot after apply when one is needednever, if-requirednever
reboot-delaydefault 5; wait before the reboot5
refreshdefault yes; refresh package lists firstyes, noyes
report-dirCSV of pending updates; default /var/lib/runbookia/reports/var/lib/runbookia/reports

Exit codes

  • 0 = No updates pending, or updates applied (and reboot scheduled if needed)
  • 1 = Updates pending (report mode), or a reboot is required and not scheduled
  • 2 = Script error, or the package manager reported a failure

Testing steps

  1. Run it first with the mode set to report on one test account or small group. Nothing is changed in that mode.
  2. Read the log and confirm the planned changes are what you expect.
  3. Run your chosen settings on the same test target and confirm the result.
  4. Check the exit code: 0 = OK, 1 = needs attention, 2 = error (see log), 9 = this copy is past its Valid until date.
  5. Roll out to a small group next, then everyone.

Rollback steps

Report mode installs nothing (it may refresh the package lists, which the system also does on its own). Apply mode installs package updates; to go back, reinstall the previous version of a package (apt-get install NAME=VERSION on Debian/Ubuntu, dnf history undo ID or dnf downgrade NAME on RHEL-family). A scheduled reboot can be cancelled with shutdown -c.

Version and change log

VersionDateChanges
1.0.0November 2026First release.