Skip to content

Linux & shell: Patching & updates

Linux & shell commands for patching & updates (tags: #patching).

Index
6 items

Linux: Check the OS release and running kernel

Safe

First step before patching: tells you which package manager to use (dnf, yum, apt, zypper, apk) and which kernel is running now.

cat /etc/os-release && uname -r
What each part does
  1. cat /etc/os-releasedistro name and version (NAME, VERSION_ID, e.g. Amazon Linux 2023, Ubuntu 22.04)
  2. uname -rthe kernel that is running right now (not necessarily the newest one installed)
Example
$ cat /etc/os-release && uname -r
NAME="Amazon Linux"
VERSION_ID="2023"
...
6.1.112-122.189.amzn2023.x86_64

Also known as: which distro · os version · kernel version · uname -r · os-release

Linux: List installed kernels

Safe

Every kernel installed on the host. Compare with uname -r to see if a newer one is waiting for a reboot.

rpm -q kernel 2>/dev/null || dpkg -l 'linux-image*' | grep ^ii
What each part does
  1. rpm -q kernelRHEL / Amazon Linux / SUSE: installed kernel packages (AL2023 may name them kernel6.12, kernel6.18: rpm -qa "kernel*")
  2. 2>/dev/null ||not an rpm system? try dpkg
  3. dpkg -l 'linux-image*' | grep ^iiDebian / Ubuntu: installed kernel images (ii = installed)
  • #linux
  • #patching
  • #kernel

Also known as: installed kernels · old kernels · kernel list

Linux: Upgrade one package on Alpine

Caution

Upgrade a single package on Alpine (usually inside a container or Dockerfile).

Dry run first
apk update && apk add --upgrade --simulate <package>
apk update && apk add --upgrade <package>
What each part does
  1. apk updaterefresh the package index
  2. apk add --upgrade <package>upgrade it to the newest version in the repo

My note Everything: apk upgrade --no-cache

  • #linux
  • #patching

Also known as: apk upgrade · alpine update package

Linux: Check versions of common runtimes on a host

Safe

Scanners flag these outside the OS package list. Compare each with the "Fixed In" version from the report.

node -v; python3 --version; java -version 2>&1 | head -1; nginx -v; git --version; /opt/splunkforwarder/bin/splunk version 2>/dev/null
What each part does
  1. node -vNode.js
  2. python3 --versionPython
  3. java -version 2>&1 | head -1Java (prints to stderr)
  4. nginx -vnginx
  5. git --versiongit
  6. splunk versionSplunk Universal Forwarder

Also known as: runtime versions · node version · python version · java version · splunk forwarder version

Linux: Find bundled Chromium binaries on a host

Safe

Puppeteer and Playwright download their own Chromium. Old copies show up as Chromium CVEs that OS patching never fixes.

sudo find / -xdev \( -name chrome -o -name chromium -o -name headless_shell \) -type f 2>/dev/null
What each part does
  1. find / -xdevsearch the root filesystem only
  2. -name chrome -o -name chromium -o -name headless_shellChromium binary names
  3. -type ffiles only

My note Fix it in the app: npm ls puppeteer, then npm install puppeteer@latest and redeploy. Delete stale ~/.cache/puppeteer folders.

  • #linux
  • #patching
  • #vulnerabilities

Also known as: chromium cve · puppeteer chromium · headless chrome · old chrome

Linux: Upgrade nginx and restart it safely

Caution

Restart only if the config still passes after the upgrade. A reload keeps the old binary running, so restart.

Dry run first
sudo dnf upgrade nginx --assumeno
sudo dnf upgrade nginx && sudo nginx -t && sudo systemctl restart nginx
What each part does
  1. dnf upgrade nginxnew nginx package (apt install --only-upgrade nginx on Ubuntu)
  2. nginx -ttest the config; stops the chain if it fails
  3. systemctl restart nginxstart the new binary
  • #linux
  • #patching
  • #systemd

Also known as: nginx update · nginx cve · upgrade nginx

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…