I'm running Debian 8 x64 and still learning it. One of the confusing things I've come across repeatedly on Debian and Ubuntu systems is there appear to be two ways of running and managing services:
service
systemctl
I've read through the Debian page on systemd (systemctl) as well as questions such as How does systemd use /etc/init.d scripts?
From what I understand so far, many Linux distributions these days, including Debian and Ubuntu, are moving away from the old SysV (System Five) and embracing systemd.
I can see that my /sbin/init
is a symbolic link to /lib/systemd/systemd
.
The question is:
- If systemd has replaced SysV, why is SysV (
service
) still there? - Why can I use both seemingly interchangeably? If I start a daemon in one, the other knows about it. How? Which one is running the show?
- Is there any real reason to use
service
any more or should I just stick tosystemctl
?
Best Answer
The
service
command is a "compatibility" tool to help people migrate from sysvinit to systemd. It's a smart program that tries to work out your currentinit
system and will call sysvinit, upstart or systemd calls as necessary.Your question is a little "tell the future" in nature; today Debian allows different init systems to work and the
service
command will try and work it all out. But Debian 9? Who knows what that will support... We could end up withsuperinit
to replacesystemd
, and theservice
command will be updated...The problem is that this solution may not be cross-platform consistent; will
service
work with CentOS or SuSE? Willsystemctl
?If I was writing my own stuff then I'd just stick with
systemctl
for allsystemd
based platforms, but have a massive test for all OS variants I support.