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.\" $FreeBSD$ 26.\" 27.Dd November 9, 2021 28.Dt SERVICE 8 29.Os 30.Sh NAME 31.Nm service 32.Nd "control (start/stop/etc.) or list system services" 33.Sh SYNOPSIS 34.Nm 35.Op Fl j Ar jail 36.Fl e 37.Nm 38.Op Fl j Ar jail 39.Fl R 40.Nm 41.Op Fl j Ar jail 42.Op Fl v 43.Fl l 44.Nm 45.Op Fl j Ar jail 46.Op Fl v 47.Fl r 48.Nm 49.Op Fl j Ar jail 50.Op Fl v 51.Op Fl E Ar var=value 52.Ar script 53.Ar command 54.Sh DESCRIPTION 55The 56.Nm 57command is an easy interface to the rc.d system. 58Its primary purpose is to start and stop services provided 59by the rc.d scripts. 60When used for this purpose it will set the same restricted 61environment that is in use at boot time 62.Po 63see 64.Sx ENVIRONMENT 65.Pc . 66It can also be used to list 67the scripts using various criteria. 68.Pp 69The options are as follows: 70.Bl -tag -width F1 71.It Fl E Ar var=value 72Set the environment variable 73.Ar var 74to the specified 75.Ar value 76before starting the script. 77This option can be used multiple times. 78.It Fl e 79List services that are enabled. 80The list of scripts to check is compiled using 81.Xr rcorder 8 82the same way that it is done in 83.Xr rc 8 , 84then that list of scripts is checked for an 85.Qq rcvar 86assignment. 87If present the script is checked to see if it is enabled. 88.It Fl j Ar jail 89Perform the given actions under the named jail. 90The 91.Ar jail 92argument can be either a jail ID or a jail name. 93.It Fl l 94List all files in 95.Pa /etc/rc.d 96and the local startup directories. 97As described in 98.Xr rc.conf 5 99this is usually 100.Pa /usr/local/etc/rc.d . 101All files will be listed whether they are an actual 102rc.d script or not. 103.It Fl R 104Restart all enabled local services. 105.It Fl r 106Generate the 107.Xr rcorder 8 108as in 109.Fl e 110above, but list all of the files, not just what is enabled. 111.It Fl v 112Be slightly more verbose. 113.El 114.Sh ENVIRONMENT 115When used to run rc.d scripts the 116.Nm 117command sets 118.Ev HOME 119to 120.Pa / 121and 122.Ev PATH 123to 124.Pa /sbin:/bin:/usr/sbin:/usr/bin 125which is how they are set in 126.Pa /etc/rc 127at boot time. 128If the 129.Fl E 130option is used, the corresponding variable is set accordingly. 131.Sh EXIT STATUS 132.Ex -std 133.Sh EXAMPLES 134The following are examples of typical usage of the 135.Nm 136command: 137.Bd -literal -offset -ident 138service named status 139service -j dns named status 140service -E LC_ALL=C.UTF-8 named start 141service -rv 142.Ed 143.Pp 144The following programmable completion entry can be used in 145.Xr csh 1 146for the names and common commands of the rc.d scripts: 147.Bd -literal -offset indent 148complete service 'c/-/(e l r v)/' 'p/1/`service -l`/' \e 149 'n/*/(start stop reload restart \e 150 status rcvar onestart onestop)/' 151.Ed 152.Pp 153The following programmable completion entry can be used in 154.Xr bash 1 155for the names of the rc.d scripts: 156.Bd -literal -offset -ident 157_service () { 158 local cur 159 cur=${COMP_WORDS[COMP_CWORD]} 160 COMPREPLY=( $( compgen -W '$( service -l )' -- $cur ) ) 161 return 0 162} 163complete -F _service service 164.Ed 165.Sh SEE ALSO 166.Xr bash 1 Pq Pa ports/shells/bash , 167.Xr rc.conf 5 , 168.Xr rc 8 , 169.Xr rcorder 8 170.Sh HISTORY 171The 172.Nm 173utility first appeared in 174.Fx 7.3 . 175.Sh AUTHORS 176This 177manual page was written by 178.An Douglas Barton Aq Mt dougb@FreeBSD.org . 179