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 -rprints. - It is instant and universal — every Unix-like system has it, no install required.
unamedescribes the kernel, not the distribution. Two servers can report identicalunameoutput 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
| Flag | Prints | Example |
|---|---|---|
-s | Kernel name | Linux |
-r | Kernel release (the version you match modules against) | 6.6.2-arch1-1 |
-v | Kernel build date/version string | #1 SMP PREEMPT_DYNAMIC ... |
-m | Machine hardware architecture | x86_64 |
-p | Processor type | x86_64 |
-o | Operating system name | GNU/Linux |
-n | Hostname (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-releasefor that (see the filesystem hierarchy for where/etclives). - 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
unamereports the distro — it reports the kernel.cat /etc/os-releaseis the distro question. - Matching module builds to
uname -vinstead ofuname -r— kernel modules are built against the release string; a one-character mismatch inuname -rmeans the module will not load. - Trusting
uname -pon every platform — on some systems it printsunknown; use-m, which is reliable. - Confusing
uname -mvalues across ecosystems —x86_64,amd64, andAMD64are all the same 64-bit Intel/AMD architecture under different names.
Related Pages
| Page | Relationship |
|---|---|
| hostnamectl | Manages the hostname uname -n reports |
| uptime | Time-based system facts, which uname does not cover |
| free | Memory facts, which uname does not cover |
| dmesg | The kernel’s own log — the natural follow-up when kernel info matters |
| journalctl | Where the distro’s services report what uname cannot |
uname Cheatsheet
| Command | What it does |
|---|---|
uname | Kernel name (Linux) |
uname -a | Everything: name, hostname, release, build, arch |
uname -r | Kernel release — the version modules match |
uname -m | Hardware architecture — for picking packages |
uname -n | Hostname of the machine |
uname -o | Operating system name (GNU/Linux) |
cat /etc/os-release | The distro question uname cannot answer |