uname command (displays information about the OS or hardware)
- Organization of this page
Format
(Windows only) uname [-a] [-m] [-n] [-r] [-s] [-v] [-w] (UNIX only) uname [-a] [-m] [-n] [-r] [-s] [-v]
Description
This command outputs information about the OS, the system host name, or hardware to the standard output.
Arguments
When this command is executed with no options specified, the processing is the same as when the -s option is specified.
- -a
-
- (Windows only)
-
When the -a option is specified and the -w option is omitted, the command displays the following information all on one line in the order shown in the following:
-
OS name (always Windows)
-
Node name
-
Information about the OS
-
Most recent service pack installed on the OS
-
OS version
-
Machine (hardware) type
When the -a option is specified and the -w option is also specified, the command displays the following information one item per line in the order shown in the following:
-
OS name, installation folder for that OS, and partition information for the disk on which the OS is installed
-
Node name
-
OS release (always unknown)
-
OS version
-
Machine (hardware) type
-
- (UNIX only)
-
The command displays the following information all on one line in the order shown in the following:
-
OS name
-
Node name
-
OS release
-
OS version
-
Machine (hardware) type
-
- -m
-
Specifies that the type of machine (hardware) is to be displayed.
- -n
-
Specifies that the node name is to be displayed.
- -r
-
Specifies that the OS release is to be displayed. In Windows, unknown is always displayed.
- -s
-
Specifies that the OS name is to be displayed.
In Windows, the command displays the following information as the OS name:
-
When the -w option is omitted, the command always displays Windows.
-
When the -w option is also specified, the command displays the OS name, installation folder for that OS, and partition information for the disk on which the OS is installed.
-
- -v
-
Specifies that the OS version is to be displayed.
- -w (Windows only)
-
Specifies that the information is to be displayed in the format used in JP1/Advanced Shell version 10-01 or earlier. When the -w option is specified, the command displays the information as follows:
-
The information about each option is displayed on a single line.
-
The information that is displayed by the -a and -s options is variable. For details, see the description of each option.
If only this option is specified, the command's processing is the same as when the -w and -s options are both specified.
-
Return codes
Return code |
Meaning |
---|---|
0 |
Normal termination |
1 or greater |
Error termination |
Notes
-
In Windows, input and output are performed in the binary mode for files and for the standard input and standard output. No conversion of end-of-line codes is performed.
-
In Windows, if an option other than those listed below is specified, a user with Administrators permissions must execute the command, because Administrators permissions are required to acquire the information. An error results if a user without Administrators permissions attempts to execute a uname command in which any option other than those listed below is specified.
-
-r option
-
-s option (when not specified together with the -w option)
-
-
In Windows, in order for the uname command to use Windows OS functions for acquiring information about the OS and hardware, the PATH environment variable must contain the Windows system folder paths at the time the script executes. If you want to add another path to the PATH environment variable, be sure to append it to the PATH environment variable as in the following example.
- Example
-
PATH="${PATH};C:\\home\\bin"
Usage examples
-
Display the default with no options specified.
Windows example:
C:\TEMP>%ADSH_OSCMD_DIR%\uname Windows
UNIX example (when the command is run in Linux):
$ /opt/jp1as/cmd/uname Linux
-
Specify the -a option to display the detailed information about the OS environment.
Windows example (when the -w option is omitted):
Windows MyMachine Microsoft Windows Server 2008 R2 Enterprise Service Pack 1 6.1.7601 x64-based PC
Windows example (when the -w option is also specified):
C:\TEMP>%ADSH_OSCMD_DIR%\uname -aw Microsoft Windows Server 2008 R2 Enterprise|C:\Windows|\Device\Harddisk0\Partition2 MyMachine unknown 6.1.7601 x64-based PC
UNIX example (when the command is run in Linux):
$ /opt/jp1as/cmd/uname -a Linux LINUX1 2.6.18-53.el5 #1 SMP Wed Oct 10 16:34:02 EDT 2007 i686
-
Specify the -m option to display the name of the machine and hardware:
C:\TEMP>%ADSH_OSCMD_DIR%\uname -m x64-based PC
-
Specify the -n option to display the node name:
C:\TEMP>%ADSH_OSCMD_DIR%\uname -n MyMachine
-
Specify the -r option to display the OS release. The following shows a Windows example that always displays unknown:
C:\TEMP>%ADSH_OSCMD_DIR%\uname -r unknown
-
Specify the -s option to display the OS name.
Windows example:
C:\TEMP>%ADSH_OSCMD_DIR%\uname -s Windows
-
Specify the -v option to display the OS version.
Windows example:
C:\TEMP>%ADSH_OSCMD_DIR%\uname -v
-
If multiple options are combined, the command displays the corresponding information according to the order defined for the -a option. A Windows example is shown below. This example specifies the -v and -s options in this order, but the information is displayed in the order of -s and -v:
6.1.7601 C:\TEMP>%ADSH_OSCMD_DIR%\uname -v -s Windows 6.1.7601
-
Display an option error message.
This message might vary depending on the platform on which the command is executed.
Windows example:
C:\TEMP>%ADSH_OSCMD_DIR%\uname -p uname: illegal option -- p usage: uname [-amnrsvw]
-
In Windows, if a user without Administrators permissions attempts to execute the uname command in which is specified an option requiring Administrator permissions, an error message is displayed as shown below. This example executes the command with the -m option specified:
C:\TEMP>%ADSH_OSCMD_DIR%\uname -m Failed to register mof file(s). Only the administrator group members can use WMIC.EXE. Reason:Win32 Error: Access is denied. unknown