]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/service/service.8
ifconfig(8): wordsmith -G and -g descriptions
[FreeBSD/FreeBSD.git] / usr.sbin / service / service.8
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 January 29, 2024
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 .Fl R
38 .Nm
39 .Op Fl j Ar jail
40 .Op Fl v
41 .Fl l
42 .Nm
43 .Op Fl j Ar jail
44 .Op Fl v
45 .Fl r
46 .Nm
47 .Op Fl j Ar jail
48 .Op Fl v
49 .Op Fl E Ar var=value
50 .Ar script
51 .Ar command
52 .Sh DESCRIPTION
53 The
54 .Nm
55 command is an easy interface to the rc.d system.
56 Its primary purpose is to start and stop services provided
57 by the rc.d scripts.
58 When used for this purpose it will set the same restricted
59 environment that is in use at boot time
60 .Po
61 see
62 .Sx ENVIRONMENT
63 .Pc .
64 It can also be used to list
65 the scripts using various criteria.
66 .Pp
67 The set of permissible values for
68 .Ar command
69 depends on the particular rc.d script being invoked.
70 For a list of standard commands which are supported by most rc.d
71 scripts, see
72 .Xr rc 8 .
73 .Pp
74 The options are as follows:
75 .Bl -tag -width F1
76 .It Fl E Ar var=value
77 Set the environment variable
78 .Ar var
79 to the specified
80 .Ar value
81 before starting the script.
82 This option can be used multiple times.
83 .It Fl e
84 List services that are enabled.
85 The list of scripts to check is compiled using
86 .Xr rcorder 8
87 the same way that it is done in
88 .Xr rc 8 ,
89 then that list of scripts is checked for an
90 .Qq rcvar
91 assignment.
92 If present the script is checked to see if it is enabled.
93 .It Fl j Ar jail
94 Perform the given actions under the named jail.
95 The
96 .Ar jail
97 argument can be either a jail ID or a jail name.
98 .It Fl l
99 List all files in
100 .Pa /etc/rc.d
101 and the local startup directories.
102 As described in
103 .Xr rc.conf 5
104 this is usually
105 .Pa /usr/local/etc/rc.d .
106 All files will be listed whether they are an actual
107 rc.d script or not.
108 .It Fl R
109 Restart all enabled local services.
110 .It Fl r
111 Generate the
112 .Xr rcorder 8
113 as in
114 .Fl e
115 above, but list all of the files, not just what is enabled.
116 .It Fl v
117 Be slightly more verbose.
118 .El
119 .Sh ENVIRONMENT
120 When used to run rc.d scripts the
121 .Nm
122 command sets
123 .Ev HOME
124 to
125 .Pa /
126 and
127 .Ev PATH
128 to
129 .Pa /sbin:/bin:/usr/sbin:/usr/bin
130 which is how they are set in
131 .Pa /etc/rc
132 at boot time.
133 If the
134 .Fl E
135 option is used, the corresponding variable is set accordingly.
136 .Sh EXIT STATUS
137 .Ex -std
138 .Sh EXAMPLES
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
141 .Xr rc 8 .
142 .Pp
143 Enable a service, then start it:
144 .Bd -literal -offset -indent
145 service sshd enable
146 service sshd start
147 .Ed
148 .Pp
149 Stop a service, then disable it:
150 .Bd -literal -offset -indent
151 service sshd stop
152 service sshd disable
153 .Ed
154 .Pp
155 Start a service which is not enabled:
156 .Bd -literal -offset -indent
157 service sshd onestart
158 .Ed
159 .Pp
160 Report the status of a service:
161 .Bd -literal -offset -ident
162 service named status
163 .Ed
164 .Pp
165 Restart a service running in a jail:
166 .Bd -literal -offset -indent
167 service -j dns named restart
168 .Ed
169 .Pp
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
173 .Ed
174 .Pp
175 Report a verbose listing of all available services:
176 .Bd -literal -offset -indent
177 service -rv
178 .Ed
179 .Pp
180 The following programmable completion entry can be used in
181 .Xr csh 1
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)/'
187 .Ed
188 .Pp
189 The following programmable completion entry can be used in
190 .Xr bash 1
191 for the names of the rc.d scripts:
192 .Bd -literal -offset -ident
193 _service () {
194         local cur
195         cur=${COMP_WORDS[COMP_CWORD]}
196         COMPREPLY=( $( compgen -W '$( service -l )' -- $cur ) )
197         return 0
198 }
199 complete -F _service service
200 .Ed
201 .Sh SEE ALSO
202 .Xr bash 1 Pq Pa ports/shells/bash ,
203 .Xr rc.conf 5 ,
204 .Xr rc 8 ,
205 .Xr rcorder 8 ,
206 .Xr sysrc 8
207 .Sh HISTORY
208 The
209 .Nm
210 utility first appeared in
211 .Fx 7.3 .
212 .Sh AUTHORS
213 This
214 manual page was written by
215 .An Douglas Barton Aq Mt dougb@FreeBSD.org .