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.Ar script 52.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 options are as follows: 69.Bl -tag -width F1 70.It Fl e 71List services that are enabled. 72The list of scripts to check is compiled using 73.Xr rcorder 8 74the same way that it is done in 75.Xr rc 8 , 76then that list of scripts is checked for an 77.Qq rcvar 78assignment. 79If present the script is checked to see if it is enabled. 80.It Fl j Ar jail 81Perform the given actions under the named jail. 82The 83.Ar jail 84argument can be either a jail ID or a jail name. 85.It Fl l 86List all files in 87.Pa /etc/rc.d 88and the local startup directories. 89As described in 90.Xr rc.conf 5 91this is usually 92.Pa /usr/local/etc/rc.d . 93All files will be listed whether they are an actual 94rc.d script or not. 95.It Fl R 96Restart all enabled local services. 97.It Fl r 98Generate the 99.Xr rcorder 8 100as in 101.Fl e 102above, but list all of the files, not just what is enabled. 103.It Fl v 104Be slightly more verbose. 105.El 106.Sh ENVIRONMENT 107When used to run rc.d scripts the 108.Nm 109command sets 110.Ev HOME 111to 112.Pa / 113and 114.Ev PATH 115to 116.Pa /sbin:/bin:/usr/sbin:/usr/bin 117which is how they are set in 118.Pa /etc/rc 119at boot time. 120.Sh EXIT STATUS 121.Ex -std 122.Sh EXAMPLES 123The following are examples of typical usage of the 124.Nm 125command: 126.Bd -literal -offset -ident 127service named status 128service -j dns named status 129service -rv 130.Ed 131.Pp 132The following programmable completion entry can be used in 133.Xr csh 1 134for the names and common commands of the rc.d scripts: 135.Bd -literal -offset indent 136complete service 'c/-/(e l r v)/' 'p/1/`service -l`/' \e 137 'n/*/(start stop reload restart \e 138 status rcvar onestart onestop)/' 139.Ed 140.Pp 141The following programmable completion entry can be used in 142.Xr bash 1 143for the names of the rc.d scripts: 144.Bd -literal -offset -ident 145_service () { 146 local cur 147 cur=${COMP_WORDS[COMP_CWORD]} 148 COMPREPLY=( $( compgen -W '$( service -l )' -- $cur ) ) 149 return 0 150} 151complete -F _service service 152.Ed 153.Sh SEE ALSO 154.Xr bash 1 Pq Pa ports/shells/bash , 155.Xr rc.conf 5 , 156.Xr rc 8 , 157.Xr rcorder 8 158.Sh HISTORY 159The 160.Nm 161utility first appeared in 162.Fx 7.3 . 163.Sh AUTHORS 164This 165manual page was written by 166.An Douglas Barton Aq Mt dougb@FreeBSD.org . 167