Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
uname prints facts about the running kernel and the hardware type. It is the quickest way to answer "which kernel runs here?" and "is this a 64-bit Intel/AMD or an ARM machine?".
Without options it prints only the kernel name (Linux). With -r you get the kernel release, which you need when you install kernel modules, read security bulletins or check that a kernel update is really active after a reboot.
Zo schrijf je het
uname [OPTION]...Opties 11
Meest gebruikt
Niets past bij dit filter.
Voorbeelden 11
$ als gewone gebruiker# als root (of met sudo)
1Show the running kernel release
uname -r 6.12.0-55.el10.x86_64el10means a kernel for RHEL 10. The last part is the CPU architecture.2Show all information on one line
uname -a Linux server1.example.com 6.12.0-55.el10.x86_64 #1 SMP PREEMPT_DYNAMIC ... x86_64 GNU/LinuxPaste this line in a bug report or a support ticket.
3Check the CPU architecture before you download software
uname -m x86_64Download the
x86_64(amd64) build for this machine, or theaarch64(arm64) build for an ARM server.4Compare the running kernel with the installed kernels
uname -r rpm -q kernelIf the newest installed kernel is not the one that runs, the server still needs a reboot to use the update.
5Find out if a reboot is needed after updates
[ "$(uname -r)" = "$(rpm -q --last kernel | head -1 | awk '{print $1}' | sed 's/^kernel-//')" ] || echo "reboot needed"A simple check for a patch script: the running kernel must be the newest installed one.
6Use the kernel release in a path
ls /lib/modules/$(uname -r)/kernel/drivers/net/Kernel modules are stored in a folder named after the kernel release.
7Print only the hostname
uname -n server1.example.comSame as the
hostnamecommand. Useful in log lines of scripts.8Pick the right binary in an install script
case "$(uname -m)" in x86_64) ARCH=amd64 ;; aarch64) ARCH=arm64 ;; *) echo "unknown arch"; exit 1 ;; esacMany tools (kubectl, terraform, trivy) name their downloads amd64 or arm64.
9Check the kernel version in an inventory report
echo "$(hostname),$(uname -r),$(uname -m)" >> /tmp/inventory.csvCollect one line per server, then compare kernel versions across the fleet.
10Show the kernel build date
uname -vA very old build date on an internet-facing server is a warning sign: patches are missing.
11Check the operating system family in a portable script
On macOS
uname -sprintsDarwin. Scripts that run on both can branch on this.
Niets past bij dit filter.
Let op
unameshows the running kernel, not the newest installed one. After a kernel update,uname -rchanges only after a reboot.-pand-ioften printunknown. Use-mfor the architecture.- The distribution version (RHEL 10.0) is not in
uname. Read/etc/redhat-releaseor/etc/os-release.
Bestanden
/proc/sys/kernel/osrelease- The kernel release (same as
uname -r). /proc/version- The full kernel version string.
/etc/os-release- Name and version of the Linux distribution.
Tips om te onthouden
- r = release (the kernel version you check most), m = machine (the CPU type), a = all.
- Kernel =
uname -r; distribution =cat /etc/redhat-release.