Determine information regarding the operating system

Author: name contact BSD flavour

Reviewer: name contact BSD flavour

Reviewer: name contact BSD flavour


Concept

Be able to determine the type and version of the operating system installed.

Introduction

The uname command can display the type and version of the operating system installed, including the system's hostname, the release level, and the hardware platform name and the processor architecture name. The -a option will show many details, and is similar to calling uname with the "-m -n -r -s -v" options.

Note that usually the kernel and userland (like libc, BSD tools and network daemons, et cetera) are kept in sync so the same version would apply for the operating system as a whole.

TODO: is "sync" term okay here? Maybe improve sentence. And should this mention that uname is for kernel only?

By default, it shows the name of the operating system:

""$ uname ""DragonFly ""$ uname -s ""DragonFly

The machine's hardware name and processor architecture name can be displayed, respectively:

""$ uname -m ""i386 ""$ uname -p ""i386

TODO: add note and example about when -m and -p are different

It can also provide the time and date of the built kernel, the host it was built on, and the path to the kernel configuration used, for example:

""$ uname -v ""DragonFly 1.7.0-DEVELOPMENT #0: Fri Oct 27 12:10:01 PDT 2006 "" jdoe@server5.example.org:/build/usr.obj/usr/src/sys/SERVER

The sysctl tool (introduced in section Modify a kernel parameter on the fly) can also show some of this same information, for example:

""$ sysctl kern.ostype ""kern.ostype = NetBSD ""$ sysctl kern.hostname ""kern.hostname = glacier.reedmedia.net ""$ sysctl kern.osrelease ""kern.osrelease = 3.99.24 ""$ sysctl kern.version ""kern.version = NetBSD 3.99.24 (JCR20060802) #0: Mon Sep 25 12:22:43 CDT 2006 reed@new-host-8:/usr/src/sys/arch/i386/compile/JCR20060802 "" ""$ sysctl hw.machine ""hw.machine = i386 ""$ sysctl hw.machine_arch ""hw.machine_arch = i386

On NetBSD, an /etc/release file also gives further details to identify the source code used to build the system.

Practice Exercises

TODO

More information

uname(1), sysctl(8); /etc/release on NetBSD