1 .\" Copyright (c) 2009 Douglas Barton
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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.
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
30 .Nd "control (start/stop/etc.) or list system services"
55 command is an easy interface to the rc.d system.
56 Its primary purpose is to start and stop services provided
58 When used for this purpose it will set the same restricted
59 environment that is in use at boot time
64 It can also be used to list
65 the scripts using various criteria.
67 The set of permissible values for
69 depends on the particular rc.d script being invoked.
70 For a list of standard commands which are supported by most rc.d
74 The options are as follows:
77 Set the environment variable
81 before starting the script.
82 This option can be used multiple times.
84 List services that are enabled.
85 The list of scripts to check is compiled using
87 the same way that it is done in
89 then that list of scripts is checked for an
92 If present the script is checked to see if it is enabled.
94 Perform the given actions under the named jail.
97 argument can be either a jail ID or a jail name.
101 and the local startup directories.
105 .Pa /usr/local/etc/rc.d .
106 All files will be listed whether they are an actual
109 Restart all enabled local services.
115 above, but list all of the files, not just what is enabled.
117 Be slightly more verbose.
120 When used to run rc.d scripts the
129 .Pa /sbin:/bin:/usr/sbin:/usr/bin
130 which is how they are set in
135 option is used, the corresponding variable is set accordingly.
139 These are some examples of the most common service commands.
140 For a full list of commands available in most rc.d scripts, see
143 Enable a service, then start it:
144 .Bd -literal -offset -indent
149 Stop a service, then disable it:
150 .Bd -literal -offset -indent
155 Start a service which is not enabled:
156 .Bd -literal -offset -indent
157 service sshd onestart
160 Report the status of a service:
161 .Bd -literal -offset -ident
165 Restart a service running in a jail:
166 .Bd -literal -offset -indent
167 service -j dns named restart
170 Start a service with a specific environment variable set:
171 .Bd -literal -offset -indent
172 service -E LC_ALL=C.UTF-8 named start
175 Report a verbose listing of all available services:
176 .Bd -literal -offset -indent
180 The following programmable completion entry can be used in
182 for the names and common commands of the rc.d scripts:
183 .Bd -literal -offset indent
184 complete service 'c/-/(e l r v)/' 'p/1/`service -l`/' \e
185 'n/*/(start stop reload restart \e
186 status rcvar onestart onestop)/'
189 The following programmable completion entry can be used in
191 for the names of the rc.d scripts:
192 .Bd -literal -offset -ident
195 cur=${COMP_WORDS[COMP_CWORD]}
196 COMPREPLY=( $( compgen -W '$( service -l )' -- $cur ) )
199 complete -F _service service
202 .Xr bash 1 Pq Pa ports/shells/bash ,
210 utility first appeared in
214 manual page was written by
215 .An Douglas Barton Aq Mt dougb@FreeBSD.org .