Linux uuname Command with Practical Examples

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, we will explore the Linux uuname command, which is used to retrieve information about the local system. The uuname command is part of the uucp (Unix-to-Unix Copy) package and provides details such as the system name, node name, release, version, and machine hardware name. We will also learn how to combine uuname with other Linux commands to perform more advanced tasks. The lab covers understanding the uuname command, retrieving system information using uuname, and combining uuname with other Linux commands.

Linux Commands Cheat Sheet


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/BasicSystemCommandsGroup(["`Basic System Commands`"]) linux(("`Linux`")) -.-> linux/TextProcessingGroup(["`Text Processing`"]) linux(("`Linux`")) -.-> linux/SystemInformationandMonitoringGroup(["`System Information and Monitoring`"]) linux/BasicSystemCommandsGroup -.-> linux/echo("`Text Display`") linux/TextProcessingGroup -.-> linux/grep("`Pattern Searching`") linux/TextProcessingGroup -.-> linux/awk("`Text Processing`") linux/SystemInformationandMonitoringGroup -.-> linux/uname("`System Information Displaying`") subgraph Lab Skills linux/echo -.-> lab-422993{{"`Linux uuname Command with Practical Examples`"}} linux/grep -.-> lab-422993{{"`Linux uuname Command with Practical Examples`"}} linux/awk -.-> lab-422993{{"`Linux uuname Command with Practical Examples`"}} linux/uname -.-> lab-422993{{"`Linux uuname Command with Practical Examples`"}} end

Understand the uuname Command

In this step, we will explore the uuname command in Linux, which is used to retrieve information about the local system. The uuname command is part of the uucp (Unix-to-Unix Copy) package, which is a set of utilities for transferring files between Unix-like systems.

To begin, let's start by checking the version of uuname installed on our system:

uuname --version

Example output:

uuname (GNU sharutils) 4.15.2
Copyright (C) 2019 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 Fran,cois Pinard.

The uuname command provides information about the local system, including the system name, node name, release, version, and machine hardware name. Let's see how we can use it to retrieve this information:

uuname -s  ## System name
uuname -n  ## Node name
uuname -r  ## Release
uuname -v  ## Version
uuname -m  ## Machine hardware name

Example output:

ubuntu
ubuntu
22.04
Ubuntu 22.04.1 LTS
x86_64

The uuname command can also be used in combination with other Linux commands to perform more advanced tasks. For example, you can use uuname with grep to filter the output:

uuname -a | grep "Ubuntu"

Example output:

ubuntu Ubuntu 22.04.1 LTS x86_64

In the next step, we will explore more practical examples of using the uuname command.

Retrieve System Information Using uuname

In this step, we will explore how to use the uuname command to retrieve detailed information about the local system.

First, let's get the basic system information using uuname without any options:

uuname

Example output:

ubuntu

This command returns the system name, which is "ubuntu" in our case.

To get more detailed information, we can use the following options:

uuname -a  ## Print all information

Example output:

ubuntu Ubuntu 22.04.1 LTS x86_64

This command prints the system name, node name, release, version, and machine hardware name.

You can also retrieve specific information using the following options:

uuname -s  ## System name
uuname -n  ## Node name
uuname -r  ## Release
uuname -v  ## Version
uuname -m  ## Machine hardware name

Example output:

ubuntu
ubuntu
22.04
Ubuntu 22.04.1 LTS
x86_64

These commands allow you to retrieve individual pieces of system information.

Additionally, you can combine uuname with other Linux commands to perform more advanced tasks. For example, you can use uuname with grep to filter the output:

uuname -a | grep "Ubuntu"

Example output:

ubuntu Ubuntu 22.04.1 LTS x86_64

This command retrieves all system information and then filters the output to only show lines containing the word "Ubuntu".

In the next step, we will explore more practical examples of using the uuname command.

Combine uuname with Other Linux Commands

In this final step, we will explore how to combine the uuname command with other Linux commands to perform more advanced tasks.

One common use case is to use uuname with grep to filter the output. For example, let's say we want to check if the system is running a specific version of Ubuntu:

uuname -a | grep "Ubuntu 22.04"

Example output:

ubuntu Ubuntu 22.04.1 LTS x86_64

This command retrieves the full system information using uuname -a and then filters the output using grep to only show lines containing the text "Ubuntu 22.04".

Another example is to use uuname with awk to extract specific pieces of information:

uuname -a | awk '{print $1, $3}'

Example output:

ubuntu 22.04

This command retrieves the full system information using uuname -a and then uses awk to print the first and third fields, which correspond to the system name and release, respectively.

You can also combine uuname with other commands to perform more complex tasks. For example, you could use uuname to get the system name and then use that information to perform other actions:

system_name=$(uuname -s)
echo "The system name is: $system_name"

Example output:

The system name is: ubuntu

This command retrieves the system name using uuname -s and stores it in the system_name variable, which can then be used in further commands or scripts.

By combining uuname with other Linux commands, you can create powerful scripts and workflows to automate various system administration tasks.

Summary

In this lab, we learned about the uuname command in Linux, which is used to retrieve information about the local system. We started by understanding the purpose of the uuname command and how to check its version. We then explored the various options available with uuname to retrieve system information, such as the system name, node name, release, version, and machine hardware name. Finally, we learned how to combine uuname with other Linux commands, like grep, to filter the output and perform more advanced tasks.

Linux Commands Cheat Sheet

Other Linux Tutorials you may like