On my system (16.04), there are the files /lib/systemd/system/network-manager.service​ and /etc/init.d/network-manager, for example.

I don't understand how (and why) this works. I always restart Network Manager by ​

Why does ​

Someone please explain how this coexistence works.

Answer

Only one init system can be active at once. On 16.04, that's systemd.

A number of packages ship with files for multiple init systems, so they can be managed with multiple init systems on different OSes. On Ubuntu, sometimes scripts for multiple init systems get installed, even though they are not all used at the same time.

Newer init systems try to maintain compatibility with older ones. In particular, systemd tries to maintain compatibility with both Upstart and SysV init scripts.

In the case of the "init.d" script you mentioned, that is a "SysV" init script, not an Upstart script. Also, "SysV" init scripts would only be started on boot if they were symlinked to a directory like "/etc/rc5.d". You'll find that Network Manager ​does not​ have a symlink installed there.

To understand how ​

Now, to answer the question about why it works to restart Network Manager with "service network-manager restart". The ​

If you review the output of ​

open("/usr/sbin/service", O_RDONLY)     = 3
...
read(10, "#!/bin/sh\n\n#####################"..., 8192) = 8192

Now that we know that ​

So while the three init systems co-exist and have some compatibility, there are layers of complexity. To minimize the complexity of what's happening going forward, it's best to use systemd unit files and the ​