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