The uname command in Linux displays system information, including the operating system name, kernel version, and more. It is useful for scripting, troubleshooting, and identifying the system’s characteristics.
Syntax:
uname [OPTION]
Options Description:
- -a, –all: Print all information in the order.
- -s, –kernel-name: Print the kernel name.
- -n, –nodename: Print the network node hostname.
- -r, –kernel-release: Print the kernel release.
- -v, –kernel-version: Print the kernel version.
- -m, –machine: Print the machine hardware name.
- -p, –processor: Print the processor type.
- -i, –hardware-platform: Print the hardware platform.
- -o, –operating-system: Print the operating system.
uname Command Examples
Here are various examples of using the uname command to retrieve system information in Linux.
Example 1: Printing general system information
$ uname
Linux
This command prints the kernel name of the operating system.
Example 2: Printing all system information
$ uname -a Linux ubuntu 3.8.0-19-generic #29-Ubuntu SMP Wed Apr 17 18:16:28 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
The -a option prints all system information, including the kernel name, network host name, kernel release, kernel version, machine hardware name, processor type, hardware platform, and operating system.
Example 3: Printing machine hardware name
$ uname -m x86_64
The -m option displays the machine hardware name, which in this case is “x86_64,” indicating a 64-bit architecture.
Example 4: Printing hardware platform information
$ uname -i x86_64
Similar to -m, the -i option shows the hardware platform information, also displaying “x86_64”.
Example 5: Printing kernel name
$ uname -s Linux
The -s option prints the kernel name, which is “Linux” in this case.
Example 6: Printing network host name
$ uname -n ubuntu
The -n option displays the network host name, revealing the system’s name within the network, which is “ubuntu” in this case.
Example 7: Printing kernel release information
$ uname -r 3.8.0-19-generic
This command uses the -r option to print the kernel release information, which is “3.8.0-19-generic” in this case.
Example 8: Printing kernel version information
$ uname -v #29-Ubuntu SMP Wed Apr 17 18:16:28 UTC 2013
The -v option prints the kernel version information, providing details such as the build or revision number and timestamp.
Example 9: Using multiple options together
$ uname -prnv ubuntu 3.8.0-19-generic #29-Ubuntu SMP Wed Apr 17 18:16:28 UTC 2013 x86_64
This command combines multiple options (-p, -r, -n, -v) to display information about the system’s name, kernel release, network host name, and kernel version, respectively.
Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.
- Check Linux Books
- Practice Programming MCQs
- Apply for Programming Internship
- Check Information Technology Books