uname - macOS


Overview

uname displays basic information about the current system, including the operating system name and version, kernel version, computer hardware name, and processor type. It’s a useful tool for system administrators and developers.

Syntax

uname [-a | -s | -n | -r | -v | -m | -p]

Options/Flags

  • -a: Print all available information.
  • -s: Print the operating system name.
  • -n: Print the hostname.
  • -r: Print the kernel version.
  • -v: Print the operating system version.
  • -m: Print the machine hardware name.
  • -p: Print the processor type.

Examples

  • Print all system information:
$ uname -a
  • Only print the operating system name:
$ uname -s
  • Print a custom message containing hardware and system information:
$ echo "You are running: $(uname -s) $(uname -r) on $(uname -m)."

Common Issues

  • Incorrect output: Check that you are running the correct version of uname and that your system supports the specified option.
  • Permission denied: Ensure you have sufficient permissions to run the command.

Integration

uname can be combined with other commands for more complex tasks:

  • Get hardware information: Use uname with system_profiler to gather detailed hardware specifications.
  • Create custom scripts: Automate system information retrieval and processing by incorporating uname into scripts.