Uname Command
Get System Information with Uname
The uname command is a fundamental utility in Unix-like
operating systems, including Linux and macOS. It is used to print
system information. This tool allows developers and system
administrators to quickly retrieve details about the operating
system kernel, hardware, and more, which is crucial for system
diagnostics, scripting, and understanding the environment.
Uname Command Usage Examples
Below are common uses of the uname command with
explanations:
Print All System Information
The -a option prints all available information.
uname -a
Example Output:
Linux system-hostname 3.2.0-4-amd64 #1 SMP Debian 3.2.32-1 x86_64 GNU/Linux
Print Hostname
Use the -n option to display the network node hostname.
uname -n
Example Output:
system-hostname
Print Kernel Release
The -r option shows the kernel release version.
uname -r
Example Output:
3.2.0-4-amd64
Print Kernel Version
For more specific kernel version details, use the
-v option.
uname -v
Example Output:
#1 SMP Debian 3.2.32-1
Print Hardware Architecture
The -m option displays the machine hardware name (e.g.,
processor type).
uname -m
Example Output:
x86_64
Print Kernel Name
Use -s to get the name of the kernel.
uname -s
Example Output:
Linux
Print Operating System
The -o option shows the operating system name.
uname -o
Example Output:
GNU/Linux
Understanding System Information
The uname command is invaluable for developers who need
to ensure their applications are compatible with specific system
configurations or for automating tasks based on the underlying OS.
For instance, knowing the kernel release can help in debugging
performance issues or understanding hardware compatibility. The
hardware architecture flag is essential for compiling software for
specific platforms.
For more in-depth information on the uname command and
its options, refer to the official Linux man pages or documentation
from your specific operating system distribution.