The uname system call fills a structure with various system information, including the computer's network name and domain name, and the operating system version it's running. Pass uname a single argument, a pointer to a struct utsname object. Include <sys/utsname.h> if you use uname.
The call to uname fills in these fields:
· sysname— The name of the operating system (such as Linux).
· release, version— The Linux kernel release number and version level.
· machine— Some information about the hardware platform running Linux. For x86 Linux, this is i386 or i686, depending on the processor.
· node— The computer's unqualified hostname.
· __domain— The computer's domain name.
Each of these fields is a character string.
The small program in Listing 8.13 prints the Linux release and version number and the hardware information.
#include <stdio.h>
#include <sys/utsname.h>
int main ()
{
struct utsname u;
uname (&u);
printf ("%s release %s (version %s) on %s\n", u.sysname, u.release,
u.version, u.machine);
return 0;
}