1.\"- 2.\" Copyright (c) 2013 Dag-Erling Smørgrav 3.\" All rights reserved. 4.\" 5.\" Redistribution and use in source and binary forms, with or without 6.\" modification, are permitted provided that the following conditions 7.\" are met: 8.\" 1. Redistributions of source code must retain the above copyright 9.\" notice, this list of conditions and the following disclaimer. 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice, this list of conditions and the following disclaimer in the 12.\" documentation and/or other materials provided with the distribution. 13.\" 14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24.\" SUCH DAMAGE. 25.\" 26.\" $FreeBSD$ 27.\" 28.Dd October 1, 2021 29.Dt FREEBSD-VERSION 1 30.Os 31.Sh NAME 32.Nm freebsd-version 33.Nd print the version and patch level of the installed system 34.Sh SYNOPSIS 35.Nm 36.Op Fl kru 37.Op Fl j Ar jail 38.Sh DESCRIPTION 39The 40.Nm 41utility makes a best effort to determine the version and patch level 42of the installed kernel and / or userland. 43.Pp 44The following options are available: 45.Bl -tag -width Fl 46.It Fl k 47Print the version and patch level of the installed kernel. 48Unlike 49.Xr uname 1 , 50if a new kernel has been installed but the system has not yet 51rebooted, 52.Nm 53will print the version and patch level of the new kernel. 54.It Fl r 55Print the version and patch level of the running kernel. 56Unlike 57.Xr uname 1 , 58this is unaffected by environment variables. 59.It Fl u 60Print the version and patch level of the installed userland. 61These are hardcoded into 62.Nm 63during the build. 64.It Fl j Ar jail 65Print the version and patch level of the installed userland in the 66given jail specified by 67.Va jid 68or 69.Va name . 70This option can be specified multiple times. 71.El 72.Pp 73If several of the above options are specified, 74.Nm 75will print the installed kernel version first, then the running kernel 76version, next the userland version, and finally the userland version 77of the specified jails, on separate lines. 78If neither is specified, it will print the userland version only. 79.Sh IMPLEMENTATION NOTES 80The 81.Nm 82utility should provide the correct answer in the vast majority of 83cases, including on systems kept up-to-date using 84.Xr freebsd-update 8 , 85which does not update the kernel version unless the kernel itself was 86affected by the latest patch. 87.Pp 88To determine the name (and hence the location) of a custom kernel, the 89.Nm 90utility will attempt to parse 91.Pa /boot/defaults/loader.conf 92and 93.Pa /boot/loader.conf , 94looking for definitions of the 95.Va kernel 96and 97.Va bootfile 98variables, both with a default value of 99.Dq kernel . 100It may however fail to locate the correct kernel if either or both of 101these variables are defined in a non-standard location, such as in 102.Pa /boot/loader.rc . 103.Sh ENVIRONMENT 104.Bl -tag -width ROOT 105.It Ev ROOT 106Path to the root of the filesystem in which to look for 107.Pa loader.conf 108and the kernel. 109.El 110.Sh EXAMPLES 111To determine the version of the currently running userland: 112.Bd -literal -offset indent 113/bin/freebsd-version -u 114.Ed 115.Pp 116To inspect a system being repaired using a live CD: 117.Bd -literal -offset indent 118mount -rt ufs /dev/ada0p2 /mnt 119env ROOT=/mnt /mnt/bin/freebsd-version -ku 120.Ed 121.Sh SEE ALSO 122.Xr uname 1 , 123.Xr loader.conf 5 124.Sh HISTORY 125The 126.Nm 127command appeared in 128.Fx 10.0 . 129.Sh AUTHORS 130The 131.Nm 132utility and this manual page were written by 133.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org . 134