unameShow the kernel name, version and architecture
uname prints facts about the running kernel: its name, release, build, the hostname and the CPU architecture. You use it to pick the right binary to download (x86_64 or aarch64), check which kernel actually booted after an update, and fill in bug reports.
uname [-a] [-s] [-n] [-r] [-v] [-m] [-o]You've logged in to an unfamiliar server and want to know the kernel and architecture before doing anything else.
unamecoreutils uname: one system call, then prints the fields you ask for, in a fixed order.
uname makes a single uname() system call, which fills a struct utsname with five strings: sysname (Linux), nodename (the hostname), release (the kernel version string), version (build number, flags such as SMP PREEMPT_DYNAMIC, and the build date) and machine (the architecture). The kernel keeps nodename in the UTS namespace, so inside a container uname -n shows the container's hostname, while release still shows the host's kernel, because containers share the host kernel. -o prints GNU/Linux, a string compiled into coreutils, not read from the kernel. -p and -i are not portable: Debian and Ubuntu patch them to print the architecture, other distributions print 'unknown'. The same data is in /proc/sys/kernel/{ostype,hostname,osrelease,version} and /proc/version.
-aEverything: name, host, release, version, machine, (processor, platform), OS-sKernel name (default with no options): Linux-nNetwork node hostname (same as hostname)-rKernel release: 6.8.0-86-generic-vKernel build: #86-Ubuntu SMP PREEMPT_DYNAMIC and the build date-mMachine architecture: x86_64, aarch64-oOperating system: GNU/Linux-p / -iProcessor / platform: non-portable, often 'unknown'Running uname -r after apt upgrade to confirm the new kerneluname reports the kernel in memory. A newly installed kernel only runs after a reboot.
Compare uname -r with ls /boot/vmlinuz-*, or check /var/run/reboot-requiredUsing uname -m output directly in download URLsProjects name architectures differently: uname says x86_64/aarch64, release pages often say amd64/arm64.
Map it in a case statement, or use dpkg --print-architectureRelying on uname -p or uname -i in portable scriptsThey are non-portable; many distributions print 'unknown'.
uname -mUsing uname inside a container to learn the container's OS versionuname reports the shared host kernel, not the image's distribution.
cat /etc/os-releaseTry these on a Linux machine of your own. Each task has a hint and a solution.
Print only the kernel release and the machine architecture, on one line.
Show the full uname output and find the hostname inside it.
Compare the running kernel with the kernels installed in /boot. (In the practice sandbox /boot is empty: a container runs on the host's kernel and has none of its own, which is the point to notice.)
Read the same release string straight from /proc.
unameShow the kernel name, version and architecture
uname prints facts about the running kernel: its name, release, build, the hostname and the CPU architecture. You use it to pick the right binary to download (x86_64 or aarch64), check which kernel actually booted after an update, and fill in bug reports.
uname [-a] [-s] [-n] [-r] [-v] [-m] [-o]You've logged in to an unfamiliar server and want to know the kernel and architecture before doing anything else.
unamecoreutils uname: one system call, then prints the fields you ask for, in a fixed order.
uname makes a single uname() system call, which fills a struct utsname with five strings: sysname (Linux), nodename (the hostname), release (the kernel version string), version (build number, flags such as SMP PREEMPT_DYNAMIC, and the build date) and machine (the architecture). The kernel keeps nodename in the UTS namespace, so inside a container uname -n shows the container's hostname, while release still shows the host's kernel, because containers share the host kernel. -o prints GNU/Linux, a string compiled into coreutils, not read from the kernel. -p and -i are not portable: Debian and Ubuntu patch them to print the architecture, other distributions print 'unknown'. The same data is in /proc/sys/kernel/{ostype,hostname,osrelease,version} and /proc/version.
-aEverything: name, host, release, version, machine, (processor, platform), OS-sKernel name (default with no options): Linux-nNetwork node hostname (same as hostname)-rKernel release: 6.8.0-86-generic-vKernel build: #86-Ubuntu SMP PREEMPT_DYNAMIC and the build date-mMachine architecture: x86_64, aarch64-oOperating system: GNU/Linux-p / -iProcessor / platform: non-portable, often 'unknown'Running uname -r after apt upgrade to confirm the new kerneluname reports the kernel in memory. A newly installed kernel only runs after a reboot.
Compare uname -r with ls /boot/vmlinuz-*, or check /var/run/reboot-requiredUsing uname -m output directly in download URLsProjects name architectures differently: uname says x86_64/aarch64, release pages often say amd64/arm64.
Map it in a case statement, or use dpkg --print-architectureRelying on uname -p or uname -i in portable scriptsThey are non-portable; many distributions print 'unknown'.
uname -mUsing uname inside a container to learn the container's OS versionuname reports the shared host kernel, not the image's distribution.
cat /etc/os-releaseTry these on a Linux machine of your own. Each task has a hint and a solution.
Print only the kernel release and the machine architecture, on one line.
Show the full uname output and find the hostname inside it.
Compare the running kernel with the kernels installed in /boot. (In the practice sandbox /boot is empty: a container runs on the host's kernel and has none of its own, which is the point to notice.)
Read the same release string straight from /proc.