Ubuntu: What is the difference between these services [duplicate]



Question:

This question already has an answer here:

What is the difference between running

service network-manager restart  

and

systemctl restart network-manager  

Why does systemctl work more?


Solution:1

service, systemd, and System V scripts

Difference is what does the job. service is a command that runs System V init scripts. systemctl is part of different init system - Systemd, to which Ubuntu has been switching since version 15.04. Both of them are service managing tools, although systemctl is backwards compatible with System V init scripts (i.e. it can do the same job as service command), but not the other way around.

Note, that your command for systemctl isn't correct. It should be systemctl restart NetworkManager. Since your question is tagged 14.04, you should read Systemd For Upstart Users article, particularly the Commands section.

Behind the Scenes

As far as Ubuntu 16.04 goes, service actually runs systemctl under the hood. See this:

bash-4.3$ sudo strace -e trace=execve service NetworkManager  restart  [sudo] password for xieerqi:   execve("/usr/sbin/service", ["service", "NetworkManager", "restart"], [/* 27 vars */]) = 0  --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=25506, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---  --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=25507, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---  --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=25508, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---  execve("/usr/local/sbin/systemctl", ["systemctl", "restart", "NetworkManager.service"], [/* 29 vars */]) = -1 ENOENT (No such file or directory)  execve("/usr/local/bin/systemctl", ["systemctl", "restart", "NetworkManager.service"], [/* 29 vars */]) = -1 ENOENT (No such file or directory)  execve("/usr/sbin/systemctl", ["systemctl", "restart", "NetworkManager.service"], [/* 29 vars */]) = -1 ENOENT (No such file or directory)  execve("/usr/bin/systemctl", ["systemctl", "restart", "NetworkManager.service"], [/* 29 vars */]) = -1 ENOENT (No such file or directory)  execve("/sbin/systemctl", ["systemctl", "restart", "NetworkManager.service"], [/* 29 vars */]) = -1 ENOENT (No such file or directory)  execve("/bin/systemctl", ["systemctl", "restart", "NetworkManager.service"], [/* 29 vars */]) = 0  --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=25509, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---  +++ exited with 0 +++  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »