How to use the command 'uname' (with examples)

How to use the command 'uname' (with examples)

  • Osx
  • December 25, 2023

The ‘uname’ command is used to print details about the current machine and the operating system running on it. It provides information such as kernel name, system architecture, processor information, kernel release, kernel version, system hostname, and more. This command is useful for retrieving specific information about the operating system and the hardware of the machine.

Use case 1: Print kernel name

Code:

uname

Motivation: Sometimes, you may need to know the kernel name of the operating system running on your machine. The kernel name represents the core part of the operating system, and it is useful for diagnosing problems related to the system’s kernel.

Explanation: By running the ‘uname’ command without any argument, it prints the kernel name of the current operating system.

Example output:

Darwin

Use case 2: Print system architecture and processor information

Code:

uname -mp

Motivation: Knowing the system architecture and processor information of a machine is essential when you want to install or run software that requires matching hardware specifications. This information can help determine compatibility and optimize performance.

Explanation: By passing the ‘-mp’ option to the ‘uname’ command, it prints the system architecture and processor information.

Example output:

x86_64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz

Use case 3: Print kernel name, kernel release, and kernel version

Code:

uname -srv

Motivation: In some situations, you may need to gather detailed information about the kernel of your operating system, including the kernel release and version. This information helps in troubleshooting kernel-related issues and determining whether specific kernel features or bug fixes are available.

Explanation: By providing the ‘-srv’ option to the ‘uname’ command, it prints the kernel name, kernel release, and kernel version.

Example output:

Darwin 18.7.0 Darwin Kernel Version 18.7.0: Tue Jul 23 16:10:16 PDT 2019; root:xnu-4903.278.28~1/RELEASE_X86_64

Use case 4: Print system hostname

Code:

uname -n

Motivation: The system hostname represents the unique name assigned to a machine on a network. It is useful in various scenarios, such as setting up network services, identifying machines in a distributed system, or troubleshooting network-related issues.

Explanation: Using the ‘-n’ option with the ‘uname’ command, it prints the system hostname.

Example output:

my-machine.local

Use case 5: Print all available system information

Code:

uname -a

Motivation: When you need to gather comprehensive information about the current machine and the operating system running on it, the ‘-a’ option of the ‘uname’ command comes in handy. It provides a detailed summary, including the kernel name, kernel release, kernel version, system architecture, system hostname, and more.

Explanation: By passing the ‘-a’ option to the ‘uname’ command, it prints all available system information.

Example output:

Darwin my-machine.local 18.7.0 Darwin Kernel Version 18.7.0: Tue Jul 23 16:10:16 PDT 2019; root:xnu-4903.278.28~1/RELEASE_X86_64 x86_64

Conclusion

The ‘uname’ command is a versatile utility that provides valuable information about the operating system and hardware of a machine. By utilizing its different options, you can retrieve specific details, such as the kernel name, system architecture, kernel version, system hostname, and more. This command serves as a fundamental tool for system administration, troubleshooting, and software compatibility checks.

Tags :

Related Posts

How to use the command 'gatsby' (with examples)

How to use the command 'gatsby' (with examples)

Gatsby is a static site generator for React that allows developers to create high-performance websites and apps.

Read More
How to use the command cowsay (with examples)

How to use the command cowsay (with examples)

Cowsay is a command-line utility that allows you to print ASCII art, with a default of a cow, saying or thinking something.

Read More
How to use the command pdfjoin (with examples)

How to use the command pdfjoin (with examples)

PDFjoin is a PDF merging utility based on pdfjam. It allows users to merge multiple PDF files into one, rearrange pages, and save the output to a new file.

Read More