Back to lessons

Linux Survival Basics

Fingerprint a Debian or Ubuntu Host

A server is described as Debian or Ubuntu, but you need the exact release fields before interpreting package output.

Command

. /etc/os-release && printf '%s %s %s\n' "$ID" "$VERSION_ID" "$VERSION_CODENAME"

What changed

Nothing changes. The command reads /etc/os-release and prints the package-relevant identity fields.

Danger

safe

When to use it

Use before debugging apt sources, package versions, upgrade paths, or OS support questions.

When not to use it

Do not use it as proof of the running kernel or CPU architecture.

Undo or recovery

No undo needed because the command is read-only.

Expected output

A compact line such as ubuntu 24.04 noble.

demo script

Disposable terminal steps

  1. cat /etc/os-release
  2. . /etc/os-release && printf '%s %s %s\n' "$ID" "$VERSION_ID" "$VERSION_CODENAME"

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.2 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
::exit-code::0
$ . /etc/os-release && printf '%s %s %s\n' "$ID" "$VERSION_ID" "$VERSION_CODENAME"
ubuntu 24.04 noble
::exit-code::0

YouTube Short

Identify the OS before apt.

Before you debug apt, read the release file. ID, version, and codename tell you which package universe the machine belongs to.

LinkedIn hook

Before package triage, prove what OS family and release you are actually on.

Question: Do you check the release codename before reading apt output?

experiments

A/B tests to run

Metric: save_rate

A: Before apt, read the OS.

B: Stop guessing the distro release.