LearnLinux FoundationsImportant Files and Paths

/etc/os-release

cat - a hands-on Linux lab on a real virtual machine.

Read a machine identity card with /etc/os-release. The KEY=VALUE format, the three load-bearing keys (PRETTY_NAME, ID, VERSION_ID), and how scripts branch on ID to pick apt or dnf. Structure-only: your machine names its own distro and version, so the drills teach the format and the moves.

Someone hands you a login to a machine and a problem to fix. The very first question, before you touch anything, is dead simple and completely load-bearing: what is this box? Is it Debian? Ubuntu? Fedora? Something else? You cannot even install a tool until you know, because Debian and Ubuntu use one installer and Fedora uses a different one.

There is a single file that answers this on almost every modern Linux machine. It is the machine's identity card, and it lives at /etc/os-release. Read it and you know exactly what you are standing on.

The black boxes in this lesson are a practice terminal: a safe sandbox that checks the one command each step teaches, so you cannot break anything. The file /etc/os-release describes a REAL machine, so its exact lines change from distribution to distribution and version to version. The output shown here is one real Debian capture, kept as an example. On the live machine at the end of the module, you read your own machine's card and it will say something different.

/etc/os-release is a small text file that names the operating system running on the machine: which distribution it is, and which version. A distribution, or distro, is one packaged flavour of Linux, like Debian, Ubuntu, or Fedora. Each ships its own version of this file, filled in with its own name and release number.

You do not need a special program to read it. It is plain text, so cat, the command you already know for printing a file to the screen, shows you the whole thing. Read the identity card now:

cat /etc/os-release

prompt: student@linuxcamp:~$ answer: cat /etc/os-release output: PRETTY_NAME="Debian GNU/Linux 13 (trixie)" NAME="Debian GNU/Linux" VERSION_ID="13" VERSION="13 (trixie)" ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" hint: Use cat, the print-a-file command, on the path /etc/os-release: cat /etc/os-release

Those exact lines belong to the machine this was captured on, a Debian 13 box. On YOUR machine the name, the version number, and the URLs will all read differently. An Ubuntu box says ID=ubuntu; a Fedora box says ID=fedora with a different version. That is the whole point: this file exists so each machine can tell you honestly what it is. What stays the same everywhere is the FORMAT, and that format is the lesson.

Look at the shape, not the words. Every line is a key, an equals sign, and a value: KEY=VALUE. The key on the left is a fixed label the system always uses. The value on the right is this machine's answer. Text values are usually wrapped in double quotes, especially when they contain spaces, like "Debian GNU/Linux 13 (trixie)". Short one-word values are often left bare with no quotes.

This is not a Debian invention. /etc/os-release is a portable standard: the same file, the same keys, on Debian, Ubuntu, Fedora, and nearly every other modern distro. Learn the keys once and you can read the identity card of any Linux machine you meet.

The quotes are part of the file, not part of the answer. When a value reads VERSION_ID="13", the release number is 13; the quotes are just how the file wraps text. You will see some values quoted and some bare in the very same file, and that is normal.

The file has several lines, but three do almost all the work. These are the ones an engineer actually reads:

Read those three lines from the capture and you know everything that matters: PRETTY_NAME tells a human it is Debian 13 (codename trixie), ID=debian is the exact name a script would test against, and VERSION_ID is the release, 13. Distro, and version. That is the identity, settled in three lines.

ID is the one to trust in a script, because it is a strict, predictable, lowercase word: debian, ubuntu, fedora. PRETTY_NAME is for humans and its wording drifts between releases, so it is the one to read with your eyes, not the one to test in code.

Often you do not want the whole card. You want one fact. Say you only care about the release number, nothing else. You can print the file and let grep, the line-finder, keep just the line whose key you want. grep VERSION_ID means show me only the lines that contain the text VERSION_ID.

Ask the machine for its version line and nothing else:

grep VERSION_ID /etc/os-release

prompt: student@linuxcamp:~$ answer: grep VERSION_ID /etc/os-release output: VERSION_ID="13" hint: grep takes the text to look for, then the file: grep VERSION_ID /etc/os-release

The version here reads 13 because this is a Debian 13 capture. Yours will show your own release number, an Ubuntu box might read 24.04, a Fedora box 41. The MOVE is what to remember: grep <KEY> /etc/os-release collapses the whole card down to the single line whose key you named. Every key in the file works this way, so grep ID or grep PRETTY_NAME pulls exactly that line.

Here is the real reason ID is unquoted and lowercase and strict. Scripts read this file to decide what to do. Because the file is KEY=VALUE, a script can source it, which means load every line as a variable it can use, and then branch on $ID. That is how one script installs software correctly on both Debian and Fedora: it checks ID and picks apt or dnf to match.

You do not write that script today. But seeing the shape explains why the format is so rigid: it is built to be read by people AND by programs. The lowercase, unquoted ID is the machine-readable half of the identity card.

This one file replaced an older mess. Distros used to scatter the same information across many differently named files, /etc/debian_version, /etc/redhat-release, and more, each with its own format. /etc/os-release unified all of it into one standard file every distro agrees on, which is exactly why you can rely on it on an unfamiliar box.

Scaffolding off. No command is printed this time. You have every piece you need.

You are on an unfamiliar machine and you want the one line that names the distro in a form a script would trust: the short, lowercase, machine-readable id. You do not want the whole card, just the line whose key is ID. Print the identity card and keep only that line.

prompt: student@linuxcamp:~$ answer: grep ID /etc/os-release output: VERSION_ID="13" ID=debian hint: Use the line-finder on the identity card, looking for the key that names the distro. Think grep, then ID, then the file /etc/os-release.

That is the everyday move. grep ID /etc/os-release searches the card and prints every line that contains the text ID, which is why you also see the VERSION_ID line come along, it too contains those two letters. The line you were after is ID=debian: lowercase, unquoted, the exact name a script would branch on. Your own machine will answer with its own id, ubuntu, fedora, or another, but the SHAPE of the answer, ID=<name>, is what every modern Linux box gives you. You recalled the file path and the line-finder from memory, which is the same recall the real machine will ask of you.

You earned this cheat sheet. Every row is something you just ran or read:

When you land on a strange machine, cat /etc/os-release is the first command to type, and ID plus VERSION_ID are the two lines that tell you which installer to use and which release you are on.

The practice terminal has shown you the shape of the identity card. You know the KEY=VALUE format, the three load-bearing keys, PRETTY_NAME, ID, VERSION_ID, and how to pull out a single line with grep. Every one of those you typed yourself.

The Important Files module ends with one real Linux machine, the Important Files capstone mission, and that is where you read a real identity card for yourself. A VM boots just for you, with its own operating system and its own /etc/os-release. It hands you objectives that use exactly what you practiced across this module: reading the system files that describe accounts, names, hardware, and, here, the machine's own identity. One difference from here: the mission shows no commands. You read the objective, you recall the command, you type it. That recall is what makes it stick.

Finish the other Important Files lessons, then go read a real machine's identity card for yourself.

Practice /etc/os-release in a real Linux terminal at The Linux Camp. Progress is verified automatically as you type commands on the machine.