Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

uname Command Guide for Printing System Information

uname prints the identity of the kernel and machine you are on — name, release, architecture — and it is the command scripts run first to figure out what kind of system they landed on.


What is uname, and Why Use It?

uname (short for unix name) answers “what am I running on?” It reports the kernel name, kernel release version, hardware architecture, and operating system details. It knows nothing about your distribution — Ubuntu, Debian, Fedora, and Arch all share the same Linux kernel and therefore report the same uname output on the same kernel version.

That distinction matters: uname is the tool for kernel facts (useful when debugging drivers, modules, or hardware), while “which distro am I on?” is a different question answered by cat /etc/os-release or the distro’s own tools.

Why Learn uname?

  • It is the first line of every good bug report — “kernel 6.6.2 on x86_64” is what kernel developers ask for first.
  • Scripts use it to branch — 32-bit vs 64-bit, or “is this even Linux?” checks start here.
  • It explains driver and module problems — kernel modules must match the exact kernel release uname -r prints.
  • It is instant and universal — every Unix-like system has it, no install required.

uname describes the kernel, not the distribution. Two servers can report identical uname output while running completely different userlands.


1. The Basic Check

uname
Linux

With no options, uname prints just the kernel name. On Linux that is always Linux; on macOS it is Darwin. That alone answers “is this a Linux box?”.

To get the full identity in one shot:

uname -a
Linux myserver 6.6.2-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 12 Dec 2024 12:00:00 +0000 x86_64 GNU/Linux
  • -a — all information: name, hostname, release, version, architecture.

2. Learn the Flags That Actually Get Used

FlagPrintsExample
-sKernel nameLinux
-rKernel release (the version you match modules against)6.6.2-arch1-1
-vKernel build date/version string#1 SMP PREEMPT_DYNAMIC ...
-mMachine hardware architecturex86_64
-pProcessor typex86_64
-oOperating system nameGNU/Linux
-nHostname (same as hostnamectl shows)myserver

The two you will type most:

uname -r    # kernel release — for modules and bug reports
uname -m    # architecture — for downloading the right binaries

uname -m is the practical one: it tells you whether to download an amd64/x86_64, arm64, or i386 package.

uname -m
aarch64

(That is how ARM 64-bit reports itself — arm64 and aarch64 are the same architecture with two names.)

3. Use It in Scripts

The classic script pattern is “detect the architecture, then act”:

case "$(uname -m)" in
    x86_64)  arch="amd64" ;;
    aarch64) arch="arm64" ;;
    *)       echo "Unsupported architecture"; exit 1 ;;
esac
echo "Downloading $arch package..."

And the classic kernel-version check — “did this fix land in my kernel?”:

# Print the kernel release, e.g. 6.6.2-arch1-1
kernel=$(uname -r)
echo "Running kernel $kernel"

4. Know What uname Does Not Tell You

uname cannot tell you:

  • Which distribution you are on — use cat /etc/os-release for that (see the filesystem hierarchy for where /etc lives).
  • How much RAM or how many cores you have — use free and nproc.
  • How long the machine has been up — use uptime.

It is a narrow tool: kernel identity, nothing more. Knowing its limits stops you from asking it questions it was never designed to answer.


Common Pitfalls

  • Assuming uname reports the distro — it reports the kernel. cat /etc/os-release is the distro question.
  • Matching module builds to uname -v instead of uname -r — kernel modules are built against the release string; a one-character mismatch in uname -r means the module will not load.
  • Trusting uname -p on every platform — on some systems it prints unknown; use -m, which is reliable.
  • Confusing uname -m values across ecosystems — x86_64, amd64, and AMD64 are all the same 64-bit Intel/AMD architecture under different names.
PageRelationship
hostnamectlManages the hostname uname -n reports
uptimeTime-based system facts, which uname does not cover
freeMemory facts, which uname does not cover
dmesgThe kernel’s own log — the natural follow-up when kernel info matters
journalctlWhere the distro’s services report what uname cannot

uname Cheatsheet

CommandWhat it does
unameKernel name (Linux)
uname -aEverything: name, hostname, release, build, arch
uname -rKernel release — the version modules match
uname -mHardware architecture — for picking packages
uname -nHostname of the machine
uname -oOperating system name (GNU/Linux)
cat /etc/os-releaseThe distro question uname cannot answer