Linux uname Command: Print System Information

By 

Updated on

5 min read

Using the uname command to print system information in Linux

Before you install a kernel module or download the right build of a package, you need to know which kernel release and architecture the machine is actually running. uname answers both in one short command, reading the kernel name, release, version, machine architecture, and hostname directly from the kernel.

This guide covers all uname options with practical examples, including how to use uname in scripts to detect system architecture.

Syntax

The general syntax of the uname command is:

txt
uname [OPTIONS]...

When invoked without any options, uname prints the kernel name:

Terminal
uname
output
Linux

uname Options

OptionLong formDescription
-s--kernel-namePrint the kernel name
-n--nodenamePrint the system hostname (same output as the hostname command)
-r--kernel-releasePrint the kernel release
-v--kernel-versionPrint the kernel version (build timestamp and flags)
-m--machinePrint the machine hardware name
-p--processorPrint the processor type (non-portable, often unknown)
-i--hardware-platformPrint the hardware platform (non-portable, often unknown)
-o--operating-systemPrint the operating system name (GNU/Linux on Linux)
-a--allPrint all of the above in the order -snrvmpio

The most common way to use uname is with the -a option to print all available information at once:

Terminal
uname -a
output
Linux dev.linuxize.com 6.8.0-51-generic #52-Ubuntu SMP PREEMPT_DYNAMIC Thu Dec  5 13:09:44 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

The fields in the output appear in the fixed order defined by uname -snrvmpio:

  • Linux - Kernel name (-s)
  • dev.linuxize.com - Hostname (-n)
  • 6.8.0-51-generic - Kernel release (-r)
  • #52-Ubuntu SMP PREEMPT_DYNAMIC Thu Dec 5 13:09:44 UTC 2024 - Kernel version (-v)
  • x86_64 - Machine hardware name (-m)
  • x86_64 - Processor architecture (-p)
  • x86_64 - Hardware platform (-i)
  • GNU/Linux - Operating system (-o)

On systems where the processor type or hardware platform cannot be determined, uname reports them as unknown and leaves them out of the -a output.

Combine Options

Options can be combined to produce only the fields you need. For example, to print the kernel release and machine architecture together:

Terminal
uname -rm
output
6.8.0-51-generic x86_64

The output always follows the fixed -a order regardless of how you order the flags. Both uname -rm and uname -mr produce the same result.

To check the kernel version running on your system:

Terminal
uname -r
output
6.8.0-51-generic

To print the hostname, use -n. On Linux, this reads the same kernel hostname as the hostname command. The uname -n command is read-only, while many hostname implementations can also change the name when run with sufficient privileges:

Terminal
uname -n
output
dev.linuxize.com

Practical Uses

Detect System Architecture in a Script

A common use of uname is to select the correct package or binary for a system. The -m option prints the machine hardware name:

Terminal
uname -m

On a 64-bit x86 system:

output
x86_64

On a 32-bit x86 system:

output
i686

You can use this value inside a shell script to handle common Linux architectures explicitly:

sh
ARCH=$(uname -m)

case "$ARCH" in
    x86_64)
        echo "Use the x86_64 build"
        ;;
    aarch64)
        echo "Use the ARM64 build"
        ;;
    i?86)
        echo "Use the 32-bit x86 build"
        ;;
    armv6l|armv7l)
        echo "Use the 32-bit ARM build"
        ;;
    *)
        echo "Unsupported architecture: $ARCH" >&2
        exit 1
        ;;
esac

This example stops on an unrecognized value instead of selecting the wrong build. Add another case when the software supports architectures such as ppc64le or s390x.

Check the Operating System Name

To print only the operating system name:

Terminal
uname -o
output
GNU/Linux

Keep in mind that -o is a GNU extension. The BSD version of uname that ships with macOS does not support it, so in scripts that must run on both systems use -s instead, which prints Linux or Darwin.

For more detailed distribution information (name, version, codename), use lsb_release instead of uname.

uname reads its values from the kernel, so it is fast but limited to what the kernel exposes. A few other commands fill the gaps.

The kernel release is also readable straight from the proc filesystem, along with the compiler used to build it:

Terminal
cat /proc/version
output
Linux version 6.8.0-51-generic (buildd@lcy02-amd64-021) (x86_64-linux-gnu-gcc-13 (Ubuntu 13.2.0-23ubuntu4) 13.2.0, GNU ld (GNU Binutils for Ubuntu) 2.42) #52-Ubuntu SMP PREEMPT_DYNAMIC Thu Dec  5 13:09:44 UTC 2024

That is the same release string uname -r returns, wrapped in build details you rarely need but that help when reporting a kernel bug.

For a formatted summary of the hostname, operating system, and kernel in one block, hostnamectl is easier to read than uname -a on systemd-based systems.

The arch command is a shorthand for uname -m and prints only the machine hardware name:

Terminal
arch
output
x86_64

When you need processor details beyond the architecture string, such as the core count, model name, or cache sizes, see the guide on getting CPU information .

Quick Reference

CommandDescription
unamePrint kernel name
uname -aPrint all system information
uname -rPrint kernel release
uname -vPrint kernel version (build info)
uname -nPrint hostname
uname -mPrint machine hardware name (x86_64, i686, etc.)
uname -pPrint processor architecture
uname -oPrint operating system name
uname -sPrint kernel name (same as no options)
uname -rmPrint kernel release and machine architecture

Conclusion

The uname command is a quick way to inspect kernel and hardware details from the command line. Use uname -a to display everything at once, or combine individual flags like -rm to print only the fields you need.

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page