xref: /freebsd/bin/freebsd-version/freebsd-version.1 (revision 0b3105a37d7adcadcb720112fed4dc4e8040be99)
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 5, 2013
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 ku
37.Sh DESCRIPTION
38The
39.Nm
40utility makes a best effort to determine the version and patch level
41of the installed kernel and / or userland.
42.Pp
43The following options are available:
44.Bl -tag -width Fl
45.It Fl k
46Print the version and patch level of the installed kernel.
47Unlike
48.Xr uname 1 ,
49if a new kernel has been installed but the system has not yet
50rebooted,
51.Nm
52will print the version and patch level of the new kernel.
53.It Fl u
54Print the version and patch level of the installed userland.
55These are hardcoded into
56.Nm
57during the build.
58.El
59.Pp
60If both
61.Fl k
62and
63.Fl u
64are specified,
65.Nm
66will print the kernel version first, then the userland version, on
67separate lines.
68If neither is specified, it will print the userland version only.
69.Sh IMPLEMENTATION NOTES
70The
71.Nm
72utility should provide the correct answer in the vast majority of
73cases, including on systems kept up-to-date using
74.Xr freebsd-update 8 ,
75which does not update the kernel version unless the kernel itself was
76affected by the latest patch.
77.Pp
78To determine the name (and hence the location) of a custom kernel, the
79.Nm
80utility will attempt to parse
81.Pa /boot/defaults/loader.conf
82and
83.Pa /boot/loader.conf ,
84looking for definitions of the
85.Va kernel
86and
87.Va bootfile
88variables, both with a default value of
89.Dq kernel .
90It may however fail to locate the correct kernel if either or both of
91these variables are defined in a non-standard location, such as in
92.Pa /boot/loader.rc .
93.Sh ENVIRONMENT
94.Bl -tag -width ROOT
95.It Ev ROOT
96Path to the root of the filesystem in which to look for
97.Pa loader.conf
98and the kernel.
99.El
100.Sh EXAMPLES
101To determine the version of the currently running userland:
102.Bd -literal -offset indent
103/bin/freebsd-version -u
104.Ed
105.Pp
106To inspect a system being repaired using a live CD:
107.Bd -literal -offset indent
108mount -rt ufs /dev/ada0p2 /mnt
109env ROOT=/mnt /mnt/bin/freebsd-version -ku
110.Ed
111.Sh SEE ALSO
112.Xr uname 1 ,
113.Xr loader.conf 5 ,
114.Xr freebsd-version 8
115.Sh HISTORY
116The
117.Nm
118command appeared in
119.Fx 10.0 .
120.Sh AUTHORS
121The
122.Nm
123utility and this manual page were written by
124.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org .
125