A terminal running `uname -a` and `lsb_release -a`

Finding Your Linux Version with uname and lsb_release

Ever wonder what Linux version is running on your machine? I commonly connect to friend's machines, or to one of my servers and I have no clue. This can make a huge difference, as some distributions use apt, and some use yum. There are two super helpful commands to accomplish figuring this out.

In this article, we're going to cover uname, and lsb_release.

TL;DR

TL;DR version is this:

Run uname -a for kernel information.

Run lsb_release -a for distribution information.

`uname`

The uname command is used to print system information, including the kernel name, release, version, and hardware platform. You can use various command line arguments to specify which information you want to see. For example, uname -s will print the kernel name, uname -r will print the kernel release, and uname -v will print the kernel version. (If you're wanting distribution information, jump down to lsb_release).

List of useful command line arguments and examples:

  • -a or --all: Prints all information (essentially uses all other flags)
    $ uname -a
    Linux deathcamel57 5.15.2-76051502-generic #202111121041~1636734399~21.10~1c02b32~dev-Ubuntu SMP Mon Nov 15 x86_64 x86_64 x86_64 GNU/Linux
  • -s or --kernel-name: Prints the kernel name
    $ uname -s
    Linux
  • -n or --nodename: Prints the network node hostname
    $ uname -n
    deathcamel57
  • -r or --kernel-release: Prints the kernel release
    $ uname -r
    5.15.2-76051502-generic
  • -v or --kernel-version: Prints the kernel version
    $ uname -v
    #202111121041~1636734399~21.10~1c02b32~dev-Ubuntu SMP Mon Nov 15
  • -m or --machine: Prints the machine hardware name
    $ uname -m
    x86_64
  • -p or --processor: Prints the processor type (architecture)
    $ uname -p
    x86_64
  • -i or --hardware-platform: Prints the hardware platform
    $ uname -i
    x86_64
  • -o or --operating-system: Prints the operating system
    $ uname -o
    GNU/Linux
  • --version: Prints the version of uname
    $ uname --version
    uname (GNU coreutils) 8.32
    Copyright (C) 2020 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    
    Written by David MacKenzie.

`lsb_release`

The lsb_release command is used to print distribution-specific information, such as the distributor ID, release, and codename. You can use various command line arguments to specify which information you want to see. For example, lsb_release -i will print the distributor ID, lsb_release -r will print the release, and lsb_release -c will print the codename.

List of useful command line arguments and examples:

  • -v or --version: Prints the version of LSB which your installation is compliant to
    $ lsb_release -v
    No LSB modules are available.
  • -i or --id: Prints the distributor's ID
    $ lsb_release -i
    Distributor ID: Ubuntu
  • -d or --description: Prints the description of the distribution currently running
    $ lsb_release -d
    Description: Ubuntu 21.10
  • -r or --release: Prints the release of distribution
    $ lsb_release -r
    Release: 21.10
  • -c or --codename: Prints the codename of the distribution
    $ lsb_release -c
    Codename: impish
  • -a or --all: Prints all information (essentially uses all other flags)
    $ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description: Ubuntu 21.10
    Release: 21.10
    Codename: impish
  • -s or --short: Prints the short output format for any information displayed (omits outputting leading headers)
    $ lsb_release -as
    No LSB modules are available.
    Ubuntu
    Ubuntu 21.10
    21.10
    impish

When to use these

The uname command is generally used to get information about the kernel that is running on a machine. This can be useful if you want to know the version of the kernel that is running, the hardware platform it is running on, or the operating system it is running on.

The lsb_release command is generally used to get information about the distribution of Linux that is running on a machine. This can be useful if you want to know the distributor ID, release, or codename of the distribution.

Both of these commands can be useful when you want to find out which version of Linux is running on a machine, but they provide different types of information. uname provides information about the kernel, while lsb_release provides information about the distribution.

In general, you might use uname if you are interested in the kernel version or hardware platform, and you might use lsb_release if you are interested in the distribution ID, release, or codename. However, you can use either command to get a general idea of which version of Linux is running on a machine.

Leave a Reply