uname
Display Linux kernel and system information
By CMD Script Team · 3 min read · Last updated
uname [OPTIONS]Options
| Flag | Description |
|---|---|
-a | Print all available system information (kernel name, hostname, release, version, machine, OS) |
-s | Print the kernel name (default with no options) |
-r | Print the kernel release, e.g. 6.8.0-45-generic |
-v | Print the kernel version/build string |
-m | Print the machine hardware name, e.g. x86_64 |
-n | Print the network node hostname |
-o | Print the operating system name, e.g. GNU/Linux |
Distribution compatibility
- Ubuntu
- Debian
- Fedora
- Arch
- macOS (BSD uname, supports -a/-r/-m but not -o)
What it does
uname (short for "Unix name") prints information about the currently running kernel and
system, such as the kernel name, release version, build details, and machine hardware
architecture. It's one of the fastest ways to answer "what kernel and architecture am I
running?" without opening any files. On its own, with no arguments, it just prints the
kernel name (Linux).
Beginner examples
uname— print the kernel name (usually justLinux)uname -r— print the kernel release, e.g.6.8.0-45-genericuname -m— print the machine hardware architecture, e.g.x86_64uname -n— print the network hostname
uname -r
Advanced examples
- Get a full one-line system summary:
uname -a - Check architecture before downloading a binary:
uname -m(e.g.aarch64vsx86_64) - Script a kernel-version gate:
[ "$(uname -r | cut -d. -f1)" -ge 5 ] && echo "modern kernel" - Combine with distro info for full context:
uname -a; cat /etc/os-release - Check the OS name field specifically on Linux:
uname -o
uname -a
Common mistakes
- Assuming
uname -areveals the distribution (Ubuntu, Fedora, etc.) — it only reports kernel-level details, not distro branding. - Using
uname -oon macOS and being surprised it fails — BSDunamedoesn't support that flag; usesw_verson macOS instead. - Parsing the free-form
uname -astring with fragile regex in scripts instead of using the single-purpose flags (-r,-m,-s) that are stable and easy to parse. - Confusing kernel release (
uname -r) with kernel version/build (uname -v) — they report different things.
Tips
- Use
uname -rin scripts that need to gate behavior on kernel version rather than parsinguname -a. - Pair
uname -mwith package manager checks when building or downloading architecture-specific software. - On systems without
lsb_release,cat /etc/os-releaseis the standard fallback for distro identification.
Best practices
- Prefer single-letter flags like
-ror-mover parsinguname -ain automation — the full string's format isn't guaranteed to stay consistent across distros. - Combine
uname -rwithuname -mwhen filing bug reports or support tickets so the exact kernel and architecture are unambiguous. - Don't rely on
unamealone to identify the Linux distribution; use it strictly for kernel/architecture facts and pair it with/etc/os-releasefor the rest.
Try it yourself
A simulated shell with a sample home directory — experiment freely, nothing leaves your browser. Type help to list supported commands.
Real-world use cases
- Confirming which kernel version is running after a kernel update and reboot.
- Determining CPU architecture before downloading a prebuilt binary or Docker image.
- Including system details (
uname -a) in bug reports or support requests. - Gating install scripts so they only run compiled binaries matching the detected architecture.
Common interview questions
- What does
uname -ashow thatuname -rdoesn't?-ashows kernel name, hostname, release, version, machine architecture, and OS name;-rshows only the kernel release string. - Can
unametell you the Linux distribution? No — it reports kernel-level info only; distro name/version comes fromlsb_release -aor/etc/os-release. - How would you script a check for 64-bit architecture?
[ "$(uname -m)" = "x86_64" ]or check foraarch64on ARM systems.
Frequently Asked Questions
What's the difference between uname -a and uname -r?
uname -a prints everything at once (kernel name, hostname, release, version, machine, and OS), while uname -r prints only the kernel release string, which is useful for scripts that need just the version number.
Does uname tell me my Linux distribution name?
No. uname reports kernel information, not distro branding — it will say Linux regardless of whether you're on Ubuntu, Fedora, or Arch. Use lsb_release -a or cat /etc/os-release for distro name and version.
Why does uname -m matter when downloading software?
It prints the CPU architecture (x86_64, aarch64, armv7l, etc.), which tells you which binary or package build to download for your machine.
Cheat sheet
Download a quick-reference cheat sheet for uname.