How to check if the distribution is Debian-based in Linux

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, you will learn how to determine if a Linux distribution is based on Debian. Understanding the underlying distribution is crucial for package management and system administration. You will use fundamental Linux commands to inspect system files and utilities that provide details about the operating system.

Specifically, you will use cat /etc/os-release to examine core OS information, lsb_release -a to verify distribution details, and cat /etc/apt/sources.list to inspect the package manager's configuration, all of which help identify Debian-based systems.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("Linux")) -.-> linux/BasicFileOperationsGroup(["Basic File Operations"]) linux(("Linux")) -.-> linux/PackagesandSoftwaresGroup(["Packages and Softwares"]) linux/BasicFileOperationsGroup -.-> linux/cat("File Concatenating") linux/PackagesandSoftwaresGroup -.-> linux/apt("Package Handling") subgraph Lab Skills linux/cat -.-> lab-558807{{"How to check if the distribution is Debian-based in Linux"}} linux/apt -.-> lab-558807{{"How to check if the distribution is Debian-based in Linux"}} end

Check OS details with cat /etc/os-release

In this step, you'll learn how to check the details of the operating system running in your LabEx environment. Knowing your OS version and distribution is crucial for installing software, troubleshooting, and understanding system behavior.

We'll use the cat command to display the contents of a specific file: /etc/os-release. This file contains information about the operating system.

The cat command is a fundamental Linux utility used to concatenate and display file content. When used with a single file argument, it simply prints the file's content to the terminal.

Type the following command in your terminal and press Enter:

cat /etc/os-release

You should see output similar to this:

PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

This output tells you several things about the operating system:

  • PRETTY_NAME: A human-readable name for the OS.
  • NAME: The name of the distribution (e.g., Ubuntu).
  • VERSION_ID: The specific version number.
  • VERSION: A more detailed version description.
  • ID: A lowercase identifier for the distribution.
  • ID_LIKE: Distributions that this one is similar to (useful for compatibility).

Understanding this information helps you know what software packages are compatible with your system and how to manage it effectively.

Click Continue to proceed to the next step.

Verify distribution with lsb_release -a

In the previous step, you used cat /etc/os-release to get OS information. Another common command to get distribution-specific information is lsb_release.

lsb_release is a command that displays Linux Standard Base (LSB) information about the Linux distribution being used. The LSB is a standard that aims to make Linux distributions more compatible with each other.

The -a option tells lsb_release to show all available LSB information.

Type the following command in your terminal and press Enter:

lsb_release -a

You should see output similar to this:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.4 LTS
Release:        22.04
Codename:       jammy

This output provides similar information to /etc/os-release but is specifically formatted according to the LSB standard.

  • Distributor ID: The ID of the distribution.
  • Description: A descriptive string.
  • Release: The release number.
  • Codename: The codename for the release.

While /etc/os-release is becoming more common, lsb_release is still widely used and useful for quickly identifying your distribution and its version.

Click Continue to move on.

Inspect apt sources with cat /etc/apt/sources.list

In this step, you'll explore where your system gets its software packages from. When you used sudo apt update and sudo apt install htop in the previous lab, apt needed to know which servers to download the software from. This information is stored in configuration files.

The primary file that lists the sources for apt is /etc/apt/sources.list. We can use the cat command again to view its contents.

Type the following command in your terminal and press Enter:

cat /etc/apt/sources.list

You will see lines starting with deb or deb-src. These lines specify the repositories (servers) where apt looks for packages.

## See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
## newer versions of the distribution.

deb http://archive.ubuntu.com/ubuntu/ jammy main restricted
## deb-src http://archive.ubuntu.com/ubuntu/ jammy main restricted

### Major bug fix updates produced after the final release of the
### distribution.
deb http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted
## deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted

### N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
### team. Also, please note that software in universe WILL NOT receive any
### review or updates from Canonical except for security updates. The
### responsibility for security updates from this repository rests entirely
### with the community.
deb http://archive.ubuntu.com/ubuntu/ jammy universe
## deb-src http://archive.ubuntu.com/ubuntu/ jammy universe
... (output may vary)

Each deb line typically follows this format:

deb [options] uri distribution [component1] [component2] [...]

  • deb: Indicates a binary package repository.
  • uri: The address of the repository (e.g., http://archive.ubuntu.com/ubuntu/).
  • distribution: The distribution codename (e.g., jammy).
  • components: Categories of software (e.g., main, restricted, universe, multiverse).

Lines starting with # are comments and are ignored by apt.

Understanding sources.list is important if you ever need to add third-party repositories to install software not available in the default sources.

Click Continue to complete this step.

Summary

In this lab, you learned how to check if a Linux distribution is Debian-based by examining system files and using specific commands. You started by using cat /etc/os-release to display detailed operating system information, including the distribution name, version, and importantly, the ID_LIKE field which indicates if the distribution is similar to Debian.

You then explored the lsb_release -a command as another method to verify distribution details, providing a standardized way to retrieve LSB (Linux Standard Base) information. Finally, you inspected the contents of /etc/apt/sources.list to identify if the system uses the apt package manager and references Debian or Debian-based repositories, which is a strong indicator of a Debian-based system. These steps provide practical methods for identifying the underlying distribution type in a Linux environment.