1.\" Copyright (c) 2009 Douglas Barton 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.Dd August 2, 2025 26.Dt SERVICE 8 27.Os 28.Sh NAME 29.Nm service 30.Nd "control (start/stop/etc.) or list system services" 31.Sh SYNOPSIS 32.Nm 33.Op Fl j Ar jail 34.Fl e 35.Nm 36.Op Fl j Ar jail 37.Op Fl q 38.Fl R 39.Nm 40.Op Fl j Ar jail 41.Op Fl v 42.Fl l 43.Nm 44.Op Fl j Ar jail 45.Op Fl v 46.Fl r 47.Nm 48.Op Fl j Ar jail 49.Op Fl dqv 50.Op Fl E Ar var=value 51.Ar script 52.Op Ar command 53.Sh DESCRIPTION 54The 55.Nm 56command is an easy interface to the rc.d system. 57Its primary purpose is to start and stop services provided 58by the rc.d scripts. 59When used for this purpose it will set the same restricted 60environment that is in use at boot time 61.Po 62see 63.Sx ENVIRONMENT 64.Pc . 65It can also be used to list 66the scripts using various criteria. 67.Pp 68The set of permissible values for 69.Ar command 70depends on the particular rc.d script being invoked. 71For a list of standard commands which are supported by most rc.d 72scripts, see 73.Xr rc 8 . 74.Pp 75The options are as follows: 76.Bl -tag -width F1 77.It Fl d 78Enable debugging. 79.It Fl E Ar var=value 80Set the environment variable 81.Ar var 82to the specified 83.Ar value 84before starting the script. 85This option can be used multiple times. 86.It Fl e 87List services that are enabled. 88The list of scripts to check is compiled using 89.Xr rcorder 8 90the same way that it is done in 91.Xr rc 8 , 92then that list of scripts is checked for an 93.Qq rcvar 94assignment. 95If present the script is checked to see if it is enabled. 96.It Fl j Ar jail 97Perform the given actions under the named jail. 98The 99.Ar jail 100argument can be either a jail ID or a jail name. 101.It Fl l 102List all files in 103.Pa /etc/rc.d 104and the local startup directories. 105As described in 106.Xr rc.conf 5 107this is usually 108.Pa /usr/local/etc/rc.d . 109All files will be listed whether they are an actual 110rc.d script or not. 111.It Fl q 112Be quiet, redirecting output to 113.Pa /dev/null . 114.It Fl R 115Restart all enabled local services. 116.It Fl r 117Generate the 118.Xr rcorder 8 119as in 120.Fl e 121above, but list all of the files, not just what is enabled. 122.It Fl v 123Be slightly more verbose. 124.El 125.Sh ENVIRONMENT 126When used to run rc.d scripts the 127.Nm 128command sets 129.Ev HOME 130to 131.Pa / 132and 133.Ev PATH 134to 135.Pa /sbin:/bin:/usr/sbin:/usr/bin 136which is how they are set in 137.Pa /etc/rc 138at boot time. 139If the 140.Fl E 141option is used, the corresponding variable is set accordingly. 142.Sh EXIT STATUS 143.Ex -std 144.Sh EXAMPLES 145These are some examples of the most common service commands. 146For a full list of commands available in most rc.d scripts, see 147.Xr rc 8 . 148.Pp 149Enable a service, then start it: 150.Bd -literal -offset indent 151service sshd enable 152service sshd start 153.Ed 154.Pp 155Stop a service, then disable it: 156.Bd -literal -offset indent 157service sshd stop 158service sshd disable 159.Ed 160.Pp 161Start a service which is not enabled: 162.Bd -literal -offset indent 163service sshd onestart 164.Ed 165.Pp 166Report the status of a service: 167.Bd -literal -offset indent 168service named status 169.Ed 170.Pp 171Restart a service running in a jail: 172.Bd -literal -offset indent 173service -j dns named restart 174.Ed 175.Pp 176Start a service with a specific environment variable set: 177.Bd -literal -offset indent 178service -E LC_ALL=C.UTF-8 named start 179.Ed 180.Pp 181Report a verbose listing of all available services: 182.Bd -literal -offset indent 183service -rv 184.Ed 185.Pp 186The following programmable completion entry can be used in 187.Xr csh 1 188for the names and common commands of the rc.d scripts: 189.Bd -literal -offset indent 190complete service 'c/-/(e l r v)/' 'p/1/`service -l`/' \e 191 'n/*/(start stop reload restart \e 192 status rcvar onestart onestop)/' 193.Ed 194.Pp 195The following programmable completion entry can be used in 196.Xr bash 1 Pq Pa ports/shells/bash 197for the names of the rc.d scripts: 198.Bd -literal -offset indent 199_service () { 200 local cur 201 cur=${COMP_WORDS[COMP_CWORD]} 202 COMPREPLY=( $( compgen -W '$( service -l )' -- $cur ) ) 203 return 0 204} 205complete -F _service service 206.Ed 207.Sh SEE ALSO 208.Xr bash 1 Pq Pa ports/shells/bash , 209.Xr rc.conf 5 , 210.Xr rc 8 , 211.Xr rcorder 8 , 212.Xr sysrc 8 213.Sh HISTORY 214The 215.Nm 216utility first appeared in 217.Fx 7.3 . 218.Sh AUTHORS 219This 220manual page was written by 221.An Douglas Barton Aq Mt dougb@FreeBSD.org . 222