FreeBSD Manual Pages
SERVICE(8) System Manager's Manual SERVICE(8) NAME service -- control (start/stop/etc.) or list system services SYNOPSIS service [-j jail] -e service [-j jail] -R service [-j jail] [-v] -l service [-j jail] [-v] -r service [-j jail] [-v] [-E var=value] script command DESCRIPTION The service command is an easy interface to the rc.d system. Its pri- mary purpose is to start and stop services provided by the rc.d scripts. When used for this purpose it will set the same restricted environment that is in use at boot time (see "ENVIRONMENT"). It can also be used to list the scripts using various criteria. The set of permissible values for command depends on the particular rc.d script being invoked. For a list of standard commands which are supported by most rc.d scripts, see rc(8). The options are as follows: -E var=value Set the environment variable var to the specified value before starting the script. This option can be used multiple times. -e List services that are enabled. The list of scripts to check is compiled using rcorder(8) the same way that it is done in rc(8), then that list of scripts is checked for an "rcvar" assignment. If present the script is checked to see if it is enabled. -j jail Perform the given actions under the named jail. The jail argument can be either a jail ID or a jail name. -l List all files in /etc/rc.d and the local startup directories. As described in rc.conf(5) this is usually /usr/local/etc/rc.d. All files will be listed whether they are an actual rc.d script or not. -R Restart all enabled local services. -r Generate the rcorder(8) as in -e above, but list all of the files, not just what is enabled. -v Be slightly more verbose. ENVIRONMENT When used to run rc.d scripts the service command sets HOME to / and PATH to /sbin:/bin:/usr/sbin:/usr/bin which is how they are set in /etc/rc at boot time. If the -E option is used, the corresponding variable is set accordingly. EXIT STATUS The service utility exits 0 on success, and >0 if an error occurs. EXAMPLES These are some examples of the most common service commands. For a full list of commands available in most rc.d scripts, see rc(8). Enable a service, then start it: service sshd enable service sshd start Stop a service, then disable it: service sshd stop service sshd disable Start a service which is not enabled: service sshd onestart Report the status of a service: service named status Restart a service running in a jail: service -j dns named restart Start a service with a specific environment variable set: service -E LC_ALL=C.UTF-8 named start Report a verbose listing of all available services: service -rv The following programmable completion entry can be used in csh(1) for the names and common commands of the rc.d scripts: complete service 'c/-/(e l r v)/' 'p/1/`service -l`/' \ 'n/*/(start stop reload restart \ status rcvar onestart onestop)/' The following programmable completion entry can be used in bash(1) for the names of the rc.d scripts: _service () { local cur cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=( $( compgen -W '$( service -l )' -- $cur ) ) return 0 } complete -F _service service SEE ALSO bash(1) (ports/shells/bash), rc.conf(5), rc(8), rcorder(8), sysrc(8) HISTORY The service utility first appeared in FreeBSD 7.3. AUTHORS This manual page was written by Douglas Barton <dougb@FreeBSD.org>. FreeBSD 14.3 January 29, 2024 SERVICE(8)
NAME | SYNOPSIS | DESCRIPTION | ENVIRONMENT | EXIT STATUS | EXAMPLES | SEE ALSO | HISTORY | AUTHORS
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=service&manpath=FreeBSD+14.3-RELEASE+and+Ports>