How-to

The uname Command: Kernel and Architecture at a Glance

uname prints facts about the running kernel and hardware architecture. It is tiny, it exists on every Unix system, and it is the right way for scripts to branch by OS or CPU type.

What does uname print by default?

$ uname
Linux

With no flags, only the kernel name. On FreeBSD it prints FreeBSD. Every other piece of information needs a flag.

What does each flag show?

FlagLong formExample output
-s--kernel-nameLinux
-n--nodenamedb-ash-01
-r--kernel-release6.12.9-amd64
-v--kernel-version#1 SMP PREEMPT_DYNAMIC Debian 6.12.9-1
-m--machinex86_64 or aarch64
-p--processoroften unknown on Linux
-i--hardware-platformoften unknown on Linux
-o--operating-systemGNU/Linux
-a--alleverything above in one line

Skip -p and -i in scripts; GNU coreutils often cannot fill them and prints unknown. Use -m for the architecture instead.

Is the version or the release the one I want?

Almost always the release, -r. Confusingly, -v is not a version number but a build description with the SMP and preempt flags and, on some distros, the build date and package version. Package managers, module folders under /lib/modules/ and bug reports all use the release string. Check the Linux kernel version explains how to read it per distro.

How do I branch a script by architecture?

Downloading the right binary is the most common use. Our range covers both x86_64 and Arm, so portable scripts matter.

case "$(uname -m)" in
  x86_64)        arch=amd64 ;;
  aarch64|arm64) arch=arm64 ;;
  *) echo "unsupported: $(uname -m)" >&2; exit 1 ;;
esac
curl -fsSLo /usr/local/bin/tool "https://downloads.example.org/tool-linux-${arch}"

Linux reports aarch64, while FreeBSD and macOS say arm64; matching both keeps the script portable. Debian based systems also offer dpkg --print-architecture, which already prints amd64 or arm64 in package naming.

How do I branch by operating system?

if [ "$(uname -s)" = "FreeBSD" ]; then
  pkg install -y rsync
else
  . /etc/os-release
  case "$ID" in
    ubuntu|debian) apt-get install -y rsync ;;
    almalinux|rocky|centos) dnf install -y rsync ;;
  esac
fi

uname only knows the kernel, so it cannot tell Ubuntu from Rocky Linux. For the distribution, read /etc/os-release, which every image we install provides. Its ID and VERSION_ID fields are stable and easy to test.

Where does uname get its data?

From the uname() system call, which returns a fixed structure filled by the kernel. The same values appear in /proc/sys/kernel/ostype, osrelease, version and hostname. Because it is one system call, uname is instant and safe to call in loops or monitoring checks.

Why does uname -n show the wrong hostname?

-n shows the kernel's hostname, which is set at boot from /etc/hostname or by hostnamectl set-hostname. If you changed /etc/hostname without running hostnamectl, the change only appears after a reboot. Our panel lets you rename the machine for your own reference; the hostname inside the OS is yours to set and is independent of that label.

Which uname line should go in a support ticket?

uname -a plus the PRETTY_NAME line from /etc/os-release. Together they show the distro, kernel release, build and architecture, which is everything needed to reproduce most problems. Do not paste the full output of tools that include IP addresses or keys unless they are needed.

How does uname differ on FreeBSD?

The flags are mostly the same, with a few extras. uname -K prints the kernel version as a number, such as 1402000, and -U the userland version; both are handy for scripts that need to compare releases numerically. uname -m prints amd64 or arm64 rather than the Linux names, and uname -p gives a meaningful processor architecture string instead of unknown. If you manage a mixed fleet, test your scripts on both before relying on any flag beyond -s, -r and -m.

How do I collect uname output from many servers?

for h in web-phx-01 web-ams-01 db-chi-01; do
  printf '%-12s ' "$h"; ssh -o BatchMode=yes "$h" 'uname -rm'
done

A short loop over SSH builds a kernel and architecture inventory in seconds, as long as key login is set up for each host. BatchMode=yes makes ssh fail instead of waiting for a password, so one unreachable host does not hang the loop. Tools like Ansible gather the same facts automatically once you have more than a handful of machines, but this loop is all you need to check that every box rebooted into the expected kernel after patch day.

Both Architectures in One Range

ServerProcessorCores / threadsMemoryStorageNetworkPer monthSmallest order
E1Intel Xeon E3-1240 v34 / 816 GB DDR32x 240 GB SSD2x 1 Gbps$30.52$91.56 (3 months)
A1Ampere Altra Q80-3080 / 80256 GB DDR42x 2 TB NVMe2x 25 Gbps$252.11$252.11 (1 month)
A3AmpereOne A96-36X96 / 96256 GB DDR51x 4 TB NVMe + 1x 1 TB NVMe (boot)2x 25 Gbps$369.75$4,437.00 (12 months)

Keep Reading

Check the Linux kernel version

Find the running kernel version, compare it with installed kernels, read what the version string means and know when a reboot is due.

Open

lscpu command

Read your server CPU details with lscpu: model, sockets, cores, threads, NUMA nodes, caches, flags and clock speeds, and what each one means.

Open

Arm vs x86 servers

How Ampere Arm processors differ from Intel and AMD x86 chips, and which jobs run cheaper on each.

Open

FreeBSD

FreeBSD 14 with ZFS in the base system and a famously solid network stack, on x86 and Arm.

Open

FAQ

Quick Answers

Run uname -m. x86_64 and aarch64 are both 64 bit.

GNU coreutils often cannot determine it on Linux. Use uname -m instead.

No. Read /etc/os-release for the distribution name and version.

-r is the release string used by packages and modules. -v is a build description.

Yes, with the same core flags. It reports FreeBSD and arm64 or amd64.