uname #sysadmin #troubleshooting - five4nets/Linux-Knowledgebase GitHub Wiki
uname
Command Tutorial
🧠 Linux The uname
command in Linux is used to display system information such as the kernel name, version, architecture, and more. It's a quick way to learn about the system you're working on—especially useful for troubleshooting, scripting, and system audits.
🧰 Basic Syntax
uname [OPTION]
If run without any options, uname
displays the kernel name by default.
🔧 Common Options
Option | Description |
---|---|
-a |
Show all system information |
-s |
Kernel name |
-n |
Network node hostname |
-r |
Kernel release |
-v |
Kernel version |
-m |
Machine hardware name |
-p |
Processor type (may return "unknown") |
-i |
Hardware platform (may return "unknown") |
-o |
Operating system |
🧪 Examples
1. Show All System Information
uname -a
Displays everything: kernel name, hostname, kernel release, version, machine, processor, hardware platform, and OS.
2. Show Kernel Name
uname -s
3. Show Hostname
uname -n
4. Show Kernel Release
uname -r
5. Show Kernel Version
uname -v
6. Show Machine Architecture
uname -m
7. Show Processor Type
uname -p
8. Show Hardware Platform
uname -i
9. Show Operating System
uname -o
🧠 Use Cases
- Scripting: Use
uname -r
to check kernel version before running kernel-specific commands. - Debugging: Use
uname -a
to provide full system info when reporting bugs. - Architecture Checks: Use
uname -m
or-p
to determine if you're on a 32-bit or 64-bit system.
📚 References
- GeeksforGeeks: uname Command in Linux
- Linux Handbook: uname Command Explained
- How-To Geek: How to Use the uname Command
- man7.org: uname(1) Manual Page
Happy system sleuthing! 🕵️♀️
Let me know if you'd like a version that includes arch
, hostname
, or lsb_release
for even deeper system insights!
From Grok
uname
Command
Tutorial: Using the Linux The uname
command in Linux is a simple yet powerful tool for retrieving system information, such as the operating system name, kernel version, hardware architecture, and more. This tutorial explains the uname
command, its options, and provides multiple examples to demonstrate its usage.
uname
Command?
What is the The uname
(short for "Unix name") command displays system information about the Linux or Unix-like system you are running. It is a built-in utility available on most Linux distributions and is commonly used for scripting, system administration, and troubleshooting.
Prerequisites
- A Linux system with access to a terminal.
- The
uname
command (pre-installed on virtually all Linux distributions). - Basic familiarity with the Linux command line.
Basic Syntax
uname [option]
- option: Flags that specify the type of system information to display (e.g.,
-a
for all information). - Without options,
uname
displays only the operating system name (e.g.,Linux
).
Common Options
The uname
command supports several options to retrieve specific system details:
-a
or--all
: Display all available system information.-s
or--kernel-name
: Display the kernel name (default if no option is specified).-n
or--nodename
: Display the network node hostname.-r
or--kernel-release
: Display the kernel release version.-v
or--kernel-version
: Display the kernel version.-m
or--machine
: Display the machine hardware name (e.g., architecture likex86_64
).-p
or--processor
: Display the processor type (may beunknown
on some systems).-i
or--hardware-platform
: Display the hardware platform (may beunknown
).-o
or--operating-system
: Display the operating system name (e.g.,GNU/Linux
).--help
: Display help information.--version
: Display theuname
version.
Examples with Explanations
Example 1: Display the Kernel Name
Retrieve the operating system kernel name.
uname
Explanation:
- Without options,
uname
outputs the kernel name, typicallyLinux
on Linux systems. - This is equivalent to
uname -s
.
Sample Output:
Linux
Example 2: Display All System Information
Show all available system details.
uname -a
Explanation:
- The
-a
option displays all system information in the following order: kernel name, hostname, kernel release, kernel version, machine hardware name, processor type, hardware platform, and operating system. - Useful for getting a complete system overview.
Sample Output:
Linux ubuntu-server 5.15.0-73-generic #80~20.04.1-Ubuntu SMP Wed Jun 14 15:32:22 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Example 3: Display Kernel Release
Check the kernel release version.
uname -r
Explanation:
- Outputs the kernel release version (e.g.,
5.15.0-73-generic
). - Useful for identifying the exact kernel version for troubleshooting or compatibility checks.
Sample Output:
5.15.0-73-generic
Example 4: Display Hostname
Retrieve the system’s network node hostname.
uname -n
Explanation:
- Displays the hostname of the system, as set in the network configuration.
- Useful for identifying the machine in a network.
Sample Output:
ubuntu-server
Example 5: Display Machine Hardware Name
Identify the system’s hardware architecture.
uname -m
Explanation:
- Outputs the machine hardware name, such as
x86_64
(64-bit) orarm
(ARM architecture). - Useful for determining software compatibility.
Sample Output:
x86_64
Example 6: Combine Multiple Options
Display specific system details together.
uname -srm
Explanation:
- Combines
-s
(kernel name),-r
(kernel release), and-m
(machine hardware name). - Outputs the kernel name, release, and architecture in a single command.
Sample Output:
Linux 5.15.0-73-generic x86_64
Example 7: Display Operating System
Show the operating system name.
uname -o
Explanation:
- Outputs the operating system name, typically
GNU/Linux
on Linux systems. - Useful for scripts that need to identify the OS.
Sample Output:
GNU/Linux
Common Use Cases
- System Identification: Use
uname -a
to gather comprehensive system details for documentation or support. - Scripting: Incorporate
uname -r
oruname -m
in scripts to check kernel versions or architecture before installing software. - Troubleshooting: Verify system compatibility for drivers or applications using
uname -m
oruname -r
. - Network Management: Use
uname -n
to confirm the system’s hostname in networked environments.
Tips and Best Practices
- Use
uname -a
for a quick system overview when troubleshooting or reporting issues. - Combine
uname
with other commands (e.g.,cat /etc/os-release
) for more detailed OS information. - In scripts, parse
uname
output with tools likeawk
orcut
for specific fields:uname -r | cut -d'-' -f1
- Be aware that
-p
and-i
may returnunknown
on some systems, depending on hardware or kernel configuration.
Caveats
- The output of
uname
is system-dependent and may vary slightly across Linux distributions or Unix-like systems (e.g., macOS, BSD). - Some options (e.g.,
-p
,-i
) may not provide meaningful output on all systems. - Requires no special permissions, but ensure you have terminal access.