Example 1
Display Kernel Name
$ uname
Linux
Displays the kernel name without any options. This is the most basic form of uname and simply outputs the operating system name. On Linux systems, this will always display "Linux". Equivalent to using the '-s' option.
Simple Check: Quick way to verify you're on a Linux system
Example 2
Display Kernel Version
$ uname -r
5.15.0-89-generic
Shows the kernel release version using the '-r' option. This displays the kernel version number, which is crucial for determining compatibility with software, drivers, and kernel modules. The format typically includes major version, minor version, patch level, and distribution-specific identifiers.
Use Case: Check kernel version for driver compatibility or security updates
Example 3
Display All System Information
$ uname -a
Linux hostname 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 9 14:15:22 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Displays all available system information using the '-a' option. This includes kernel name, hostname, kernel release, kernel version, machine hardware name, processor type, hardware platform, and operating system. The most comprehensive single command for system identification.
Complete Info: Most commonly used uname option for full system details
Example 4
Display Hostname
$ uname -n
webserver01
Shows the network node hostname using the '-n' option. This is the name by which the system is known on the network. Useful in scripts to identify which machine is executing commands, especially in multi-server environments or when managing remote systems.
Alternative: The 'hostname' command does the same thing more explicitly
Example 5
Display Machine Hardware Name
$ uname -m
x86_64
Displays the machine hardware name (architecture) using the '-m' option. Common values include x86_64 (64-bit Intel/AMD), i686 (32-bit Intel), aarch64 (64-bit ARM), armv7l (32-bit ARM). Critical for determining which software packages or binaries to download and install.
Package Selection: Essential for downloading correct architecture-specific binaries
Example 6
Display Processor Type
$ uname -p
x86_64
Shows the processor type using the '-p' option. On many systems, this may output "unknown" or the same value as '-m'. The information depends on what the kernel knows about the processor. More detailed processor information is typically found in /proc/cpuinfo.
Note: Often returns "unknown" on modern Linux systems; use lscpu for detailed CPU info
Example 7
Display Hardware Platform
$ uname -i
x86_64
Shows the hardware platform using the '-i' option. Similar to '-m', this displays the hardware platform identifier. On many systems, this is identical to the machine hardware name. Not supported on all Unix-like systems.
Platform Info: Useful for determining hardware compatibility
Example 8
Display Operating System Name
$ uname -o
GNU/Linux
Shows the operating system name using the '-o' option. On Linux systems, this typically displays "GNU/Linux" acknowledging both the GNU tools and Linux kernel. This distinguishes between different Unix-like operating systems (Linux, FreeBSD, Solaris, etc.).
OS Identification: Useful in scripts that need to handle different Unix-like systems
Example 9
Display Kernel Version Details
$ uname -v
#99-Ubuntu SMP Mon Oct 9 14:15:22 UTC 2025
Shows the kernel version with build information using the '-v' option. This includes the build number, distribution identifier (like Ubuntu), SMP (Symmetric Multi-Processing) indicator, and the date/time when the kernel was compiled. More detailed than '-r'.
Build Info: Includes compilation date and distribution-specific details
Example 10
Custom Output with Multiple Options
$ uname -srm
Linux 5.15.0-89-generic x86_64
Combines multiple options to display specific information: '-s' (kernel name), '-r' (kernel release), '-m' (machine hardware). You can combine any options to get exactly the information you need. This is useful in scripts where you only need specific details without the full output of '-a'.
Customization: Combine options in any order to get exactly what you need
Bonus 1
Use in Scripts for System Detection
#!/bin/bash
# Detect system architecture
ARCH=$(uname -m)
case $ARCH in
x86_64)
echo "64-bit Intel/AMD system"
PACKAGE="app-amd64.deb"
;;
aarch64)
echo "64-bit ARM system"
PACKAGE="app-arm64.deb"
;;
armv7l)
echo "32-bit ARM system"
PACKAGE="app-armhf.deb"
;;
*)
echo "Unknown architecture: $ARCH"
exit 1
;;
esac
echo "Installing: $PACKAGE"
64-bit Intel/AMD system
Installing: app-amd64.deb
Demonstrates how to use uname in scripts for architecture-specific operations. This pattern is commonly used in installation scripts to download and install the correct binary package for the system architecture. Essential for cross-platform shell scripts.
Real World: Used in installation scripts, build systems, and deployment automation
Bonus 2
Check Kernel Version for Compatibility
#!/bin/bash
# Check if kernel version meets minimum requirement
KERNEL_VERSION=$(uname -r | cut -d. -f1,2)
REQUIRED_VERSION="5.10"
if [ "$(printf '%s\n' "$REQUIRED_VERSION" "$KERNEL_VERSION" | sort -V | head -n1)" = "$REQUIRED_VERSION" ]; then
echo "Kernel version $KERNEL_VERSION meets requirement (>= $REQUIRED_VERSION)"
else
echo "Kernel version $KERNEL_VERSION is too old. Need >= $REQUIRED_VERSION"
exit 1
fi
Kernel version 5.15 meets requirement (>= 5.10)
Shows how to parse and compare kernel versions in scripts. This is crucial for software that requires minimum kernel versions for specific features or compatibility. The script extracts the major.minor version and performs version comparison.
Version Checks: Essential for ensuring system compatibility before installation
Reference
uname Command Options Quick Reference
Basic Options:
uname Display kernel name (same as -s)
uname -a Display all information
uname -s Kernel name (Linux)
uname -n Network node hostname
uname -r Kernel release version
uname -v Kernel version (build info)
uname -m Machine hardware name (architecture)
uname -p Processor type
uname -i Hardware platform
uname -o Operating system name
Common Combinations:
uname -sr Kernel name and release
uname -srm Kernel, release, and architecture
uname -nrm Hostname, kernel, and arch
Typical Outputs:
Architecture:
x86_64 64-bit Intel/AMD
i686 32-bit Intel
aarch64 64-bit ARM
armv7l 32-bit ARM
Kernel Release Format:
5.15.0-89-generic
| | | | └─ Distribution identifier
| | | └───── Build number
| | └─────── Patch level
| └────────── Minor version
└───────────── Major version
Script Usage Examples:
# Get architecture
ARCH=$(uname -m)
# Get kernel version
KERNEL=$(uname -r)
# Get hostname
HOST=$(uname -n)
# Check if 64-bit system
if [ "$(uname -m)" = "x86_64" ]; then
echo "64-bit system"
fi
# Distribution detection
OS=$(uname -o)
KERNEL=$(uname -s)
# Full system info for logs
echo "System: $(uname -a)" >> /var/log/install.log
Alternative Commands:
lsb_release -a Distribution information
hostnamectl Detailed system information
cat /etc/os-release Distribution details
cat /proc/version Kernel version details
lscpu CPU architecture info
arch Architecture (shortcut for uname -m)
Common Use Cases:
1. Check kernel version for driver compatibility
2. Determine architecture for package downloads
3. Identify system in multi-server environments
4. Script conditional logic based on OS/arch
5. Log system information for support tickets
6. Verify system meets software requirements
Comprehensive reference for uname command including all options, typical outputs, script usage patterns, and related commands for system information gathering.