The Linux Fragmentation Problem
If you are using Windows, it is incredibly easy to know what operating system you are running. Your computer either has Windows 10 or Windows 11. Linux is entirely different. Because Linux is open-source, thousands of different developers have taken the core kernel and built their own custom operating systems on top of it. These are called “distributions” (or distros).
If you have just been handed the login credentials to a remote server, or if you are trying to install a new piece of software on an old laptop you found in the closet, you absolutely must know which distribution of Linux you are running. A software package designed for Ubuntu (a Debian-based distro) will completely fail to install on a machine running CentOS or Fedora (Red Hat-based distros).
You cannot rely on the graphical user interface (GUI) to tell you, because two completely different Linux distributions might use the exact same GNOME desktop environment. Instead, you need to ask the operating system directly using the command line.
The Best Method: The os-release Command
While there are several ways to check your Linux version, there is one modern command that works universally across almost every major distribution created in the last ten years (since the widespread adoption of systemd).
- Open your Linux Terminal (usually by pressing Ctrl + Alt + T on a desktop, or simply logging into your server via SSH).
- Type the following command and press Enter:
cat /etc/os-release
This command simply reads a specific text file located in the /etc/ directory and prints the contents to your screen.
How to Read the Output:
Your terminal will output a list of variables. The three most important lines you need to look for are:
- NAME: This tells you the primary distribution family (e.g., Ubuntu, Debian, Fedora, Alpine Linux).
- VERSION: This tells you the exact release number (e.g., “22.04.3 LTS (Jammy Jellyfish)”). This is critical, as software repositories frequently change between version numbers.
- ID_LIKE: If you are running a smaller, obscure distribution (like Linux Mint or Pop!_OS), this line tells you which major family it is based on (e.g., “ubuntu debian”). This is extremely helpful when looking up troubleshooting guides online.
Alternative Method 1: The hostnamectl Command
If the os-release file provides too much cluttered information and you just want a clean summary of your system, you can use the hostname control command.
- In your terminal, type:
hostnamectl - Press Enter.
Look for the line that says Operating System:. It will clearly state the distro and version number (e.g., Operating System: Ubuntu 24.04 LTS). This command will also tell you whether you are running a 64-bit or 32-bit architecture, and what version of the underlying Linux kernel you are currently using.
Alternative Method 2: The lsb_release Command
If you are working on a very old system, or if the two commands above return “command not found” errors, you can try the Linux Standard Base command.
- In your terminal, type:
lsb_release -a - Press Enter.
The terminal will print a clean, four-line summary displaying the Distributor ID, Description, Release, and Codename. However, be aware that this command is slowly being phased out in newer, minimal server environments, so it may not be installed by default on a fresh cloud server.
Finding Your Kernel Version
Sometimes, knowing the distribution name (like Ubuntu 22.04) is not enough. If you are trying to compile a custom driver for a graphics card or a Wi-Fi adapter, the instructions will specifically ask for your exact Linux Kernel Version.
To find this quickly, simply type:
uname -r
The terminal will output a short string of numbers (e.g., 6.8.0-40-generic). This is the exact version of the core kernel managing the hardware on your machine.