Linux uname Command: Print System Information

By 

Updated on

4 min read

Using the uname command to print system information in Linux

uname is a command-line utility that prints basic information about the operating system and system hardware, including the kernel name, version, release, machine architecture, and hostname.

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 architecture
-i--hardware-platformPrint the hardware platform
-o--operating-systemPrint the operating system name (GNU/Linux on Linux)
-a--allPrint all of the above, equivalent to -snrvmo

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)

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. This produces the same result as the hostname command:

Terminal
uname -n
output
dev.linuxize.com

Practical Uses

Detect System Architecture in a Script

A common use of uname is to detect whether a system is 32-bit or 64-bit before installing or compiling software. The -m option prints the machine hardware name:

Terminal
uname -m

On a 64-bit system:

output
x86_64

On a 32-bit system:

output
i686

You can use this inside a shell script to branch based on architecture:

sh
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
    echo "64-bit system detected"
else
    echo "32-bit or non-x86 system detected"
fi

Check the Operating System Name

To print only the operating system name:

Terminal
uname -o
output
GNU/Linux

This is useful in scripts that may run on multiple platforms, such as Linux and macOS.

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

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

FAQ

What is the difference between uname -r and uname -v?
-r prints the kernel release string (e.g., 6.8.0-51-generic), which identifies the kernel version number. -v prints the kernel version string, which contains the build number, compilation flags, and timestamp. For most purposes, -r is the one you want.

What does x86_64 in uname -m mean?
x86_64 means the system is running a 64-bit x86 processor. A 32-bit system would show i686 or i386. ARM systems show values like aarch64 (64-bit ARM) or armv7l (32-bit ARM).

How is uname -n different from the hostname command?
They produce the same output — both print the system’s network hostname. uname -n reads the nodename from the kernel, while hostname uses its own lookup. In practice they are interchangeable for reading the hostname.

How do I check which Linux distribution I am running?
uname only reports kernel information, not the distribution name or version. To identify the distribution, use lsb_release -a, cat /etc/os-release, or see the check Linux version guide.

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.

If you have any questions, feel free to leave a comment below.

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