service is an "high-level" command used for start, restart, stop and status
services in different Unixes and Linuxes. Depending on the
"lower-level" service manager, service redirects on different
For example, on CentOS 7 it redirects to
systemctl, while on CentOS 6 it directly
called the relative
/etc/init.d script. On the
other hand, in older Ubuntu releases it redirects to upstart.
service is adequate for basic service management, while directly calling
give greater control options.
In RHEL6 you first add the service:
chkconfig --add SERVICE
then to enable or disable:
chkconfig SERVICE on
chkconfig SERVICE off
Check if service is enabled:
chkconfig SERVICE --list
You can also in RHEL7 and higher turn the service on like this for start on next boot or other trigger:
systemctl enable SERVICE
Note that all recent versions of
systemctl assume the ".service" if left off.
systemctl enable lircmd
Systemd brings everything that you used to do with
service under one command,
systemctl, so I generally find that easier to cope with in the long run.
update-rc.d requires dependency and
runlevel information to be provided in the
init.d script LSB comment header of all
Add a block like this in the
### BEGIN INIT INFO
# Provides: scriptname
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
The service command is a wrapper script that allows system administrators to start, stop, and check the status of services without worrying too much about the actual
init system being used. Prior to systemd's introduction, it was a wrapper for
/etc/init.d scripts and Upstart's
initctl command, and now it is a wrapper for these two and systemctl as well.
service(8) System Manager's Manual service(8)
service - run a System V init script
service SCRIPT COMMAND [OPTIONS]
service --help | -h | --version
service runs a System V init script, systemd unit, or upstart job in as predictable an environment as possible, removing most environment variables and with the current working directory set to /.
The SCRIPT parameter specifies a System V init script, located in /etc/init.d/SCRIPT, or the name of a systemd unit, or the name of an upstart job in /etc/init. The existence of a systemd unit or upstart job of the same name
as a script in /etc/init.d will cause the unit/job to take precedence over the init.d script. The supported values of COMMAND depend on the invoked script. service passes COMMAND and OPTIONS to the init script unmodified.
For systemd units or upstart jobs, start, stop, status, and reload are passed through to their systemctl/initctl equivalents. For upstart jobs, restart will call the upstart 'stop' for the job, followed immediately by the
'start', and will exit with the return code of the start command.
All scripts should support at least the start and stop commands. As a special case, if COMMAND is --full-restart, the script is run twice, first with the stop command, then with the start command. This option has no effect
on upstart jobs.
service --status-all runs all init scripts, in alphabetical order, with the status command. The status is [ + ] for running services, [ - ] for stopped services and [ ? ] for services without a 'status' command. This
option only calls status for sysvinit jobs; upstart jobs can be queried in a similar manner with initctl list.
service calls the init script and returns the status returned by it.
The directory containing System V init scripts.
The directory containing upstart jobs.
The directories containing systemd units.
LANG, LANGUAGE, LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES, LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEASUREMENT, LC_IDENTIFICATION, LC_ALL, TERM, PATH
The only environment variables passed to the init scripts.
service vs. systemctl scripts -- which to use