Linux uname Command with Practical Examples

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, you will learn how to use the Linux uname command to retrieve detailed information about your system's hardware and software configurations. The uname command provides various options to display the kernel name, operating system, processor type, and other system details. You will explore the basic usage of uname and learn how to combine different options to get comprehensive system information. This lab covers the essential skills for system monitoring and management on Linux platforms.

Linux Commands Cheat Sheet


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/BasicFileOperationsGroup(["`Basic File Operations`"]) linux(("`Linux`")) -.-> linux/BasicSystemCommandsGroup(["`Basic System Commands`"]) linux(("`Linux`")) -.-> linux/SystemInformationandMonitoringGroup(["`System Information and Monitoring`"]) linux/BasicFileOperationsGroup -.-> linux/cat("`File Concatenating`") linux/BasicSystemCommandsGroup -.-> linux/echo("`Text Display`") linux/SystemInformationandMonitoringGroup -.-> linux/uname("`System Information Displaying`") linux/SystemInformationandMonitoringGroup -.-> linux/hostname("`Hostname Managing`") subgraph Lab Skills linux/cat -.-> lab-422973{{"`Linux uname Command with Practical Examples`"}} linux/echo -.-> lab-422973{{"`Linux uname Command with Practical Examples`"}} linux/uname -.-> lab-422973{{"`Linux uname Command with Practical Examples`"}} linux/hostname -.-> lab-422973{{"`Linux uname Command with Practical Examples`"}} end

Understand the uname Command

In this step, you will learn about the uname command, which is used to retrieve information about the operating system and hardware of the Linux system.

The uname command provides various options to display different types of system information, such as the kernel name, operating system, processor type, and more.

To get started, let's explore the basic usage of the uname command:

uname

Example output:

Linux

The basic uname command without any options will display the kernel name, which is "Linux" in this case.

Now, let's try some common options to get more detailed information:

uname -s  ## Print the kernel name
uname -n  ## Print the network node hostname
uname -r  ## Print the kernel release
uname -v  ## Print the kernel version
uname -m  ## Print the machine hardware name
uname -p  ## Print the processor type
uname -i  ## Print the hardware platform
uname -o  ## Print the operating system

Example output:

Linux
labex-docker
5.15.0-1023-aws
#25~22.04.1-Ubuntu SMP Thu Apr 13 15:45:57 UTC 2023
x86_64
x86_64
x86_64
GNU/Linux

As you can see, each option provides a specific piece of system information. You can combine these options to get a more comprehensive output:

uname -a  ## Print all system information

Example output:

Linux labex-docker 5.15.0-1023-aws #25~22.04.1-Ubuntu SMP Thu Apr 13 15:45:57 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

The -a (or --all) option will display all the available system information in a single command.

Retrieve System Information Using uname

In this step, you will learn how to use the uname command to retrieve detailed information about your Linux system's hardware and software configurations.

Let's start by exploring the different options available with the uname command:

uname -s  ## Print the kernel name
uname -n  ## Print the network node hostname
uname -r  ## Print the kernel release
uname -v  ## Print the kernel version
uname -m  ## Print the machine hardware name
uname -p  ## Print the processor type
uname -i  ## Print the hardware platform
uname -o  ## Print the operating system

Example output:

Linux
labex-docker
5.15.0-1023-aws
#25~22.04.1-Ubuntu SMP Thu Apr 13 15:45:57 UTC 2023
x86_64
x86_64
x86_64
GNU/Linux

You can combine these options to get a more comprehensive output:

uname -a  ## Print all system information

Example output:

Linux labex-docker 5.15.0-1023-aws #25~22.04.1-Ubuntu SMP Thu Apr 13 15:45:57 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

The -a (or --all) option will display all the available system information in a single command.

To further explore the system information, you can use the following commands:

cat /etc/os-release  ## Display detailed OS information
lsb_release -a       ## Display Linux distribution information

Example output:

NAME="Ubuntu"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 22.04.1 LTS"
VERSION_ID="22.04"
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"
VERSION_CODENAME=jammy
UBUNTU_CODENAME=jammy

These commands provide additional details about the operating system, such as the distribution name, version, and codename.

Combine uname Options for Detailed Output

In this step, you will learn how to combine multiple uname options to get a more detailed and comprehensive output about your Linux system.

While the individual uname options provide specific system information, you can combine them to get a complete overview of your system's hardware and software configurations.

Let's start by using the -a (or --all) option, which will display all available system information in a single command:

uname -a

Example output:

Linux labex-docker 5.15.0-1023-aws #25~22.04.1-Ubuntu SMP Thu Apr 13 15:45:57 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

This command provides the following information:

  • Kernel name: Linux
  • Hostname: labex-docker
  • Kernel release: 5.15.0-1023-aws
  • Kernel version: #25~22.04.1-Ubuntu SMP Thu Apr 13 15:45:57 UTC 2023
  • Machine hardware name: x86_64
  • Processor type: x86_64
  • Hardware platform: x86_64
  • Operating system: GNU/Linux

If you want to focus on specific aspects of the system information, you can combine the individual options:

uname -snrvm

Example output:

Linux 5.15.0-1023-aws x86_64 x86_64

This command displays the kernel name, release, version, and machine hardware name.

You can also use the lsb_release command to get additional details about the Linux distribution:

lsb_release -a

Example output:

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

This command provides information about the Linux distribution, including the distributor ID, description, release, and codename.

By combining the uname and lsb_release commands, you can get a comprehensive overview of your Linux system's hardware and software configurations.

Summary

In this lab, you learned about the uname command, which is used to retrieve information about the operating system and hardware of the Linux system. You explored the basic usage of the uname command and the various options it provides to display different types of system information, such as the kernel name, operating system, processor type, and more. You also learned how to combine these options to get a more comprehensive output using the -a (or --all) option.

Furthermore, you discovered how to use the uname command to retrieve detailed information about your Linux system's hardware and software configurations, including the kernel name, network node hostname, kernel release, kernel version, machine hardware name, processor type, hardware platform, and operating system.

Linux Commands Cheat Sheet

Other Linux Tutorials you may like