uname – print system information

uname command
uname command

uname prints system information including kernel name, version, and architecture.

Synopsis

uname [OPTIONS]

Common Options

OptionDescription
-aAll information
-sKernel name
-nNetwork hostname
-rKernel release
-vKernel version
-mMachine hardware
-pProcessor type
-oOperating system

Examples

All information

$ uname -a
Linux server 5.15.0-91-generic #101-Ubuntu SMP x86_64 GNU/Linux

Kernel name

$ uname -s
Linux

Kernel version

$ uname -r
5.15.0-91-generic

Architecture

$ uname -m
x86_64

Operating system

$ uname -o
GNU/Linux

Common Patterns

Check if Linux or macOS

if [ "$(uname -s)" = "Linux" ]; then
    echo "Running on Linux"
elif [ "$(uname -s)" = "Darwin" ]; then
    echo "Running on macOS"
fi

Check architecture

$ uname -m
x86_64    # 64-bit Intel/AMD
aarch64   # 64-bit ARM
armv7l    # 32-bit ARM

More Detailed Info

# Linux distribution
$ cat /etc/os-release
$ lsb_release -a

# macOS version
$ sw_vers

# Full system info
$ hostnamectl    # systemd systems

See Also

Tutorials