SysV, Upstart and systemd init script coexistence












11















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 sudo service network-manager restart. Shouldn't this mess up systemd somehow? It still seems to work.



Why does service --status-all list all kinds of services? Shouldn't 16.04 use systemd instead of Upstart?



Someone please explain how this coexistence works.










share|improve this question





























    11















    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 sudo service network-manager restart. Shouldn't this mess up systemd somehow? It still seems to work.



    Why does service --status-all list all kinds of services? Shouldn't 16.04 use systemd instead of Upstart?



    Someone please explain how this coexistence works.










    share|improve this question



























      11












      11








      11


      1






      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 sudo service network-manager restart. Shouldn't this mess up systemd somehow? It still seems to work.



      Why does service --status-all list all kinds of services? Shouldn't 16.04 use systemd instead of Upstart?



      Someone please explain how this coexistence works.










      share|improve this question
















      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 sudo service network-manager restart. Shouldn't this mess up systemd somehow? It still seems to work.



      Why does service --status-all list all kinds of services? Shouldn't 16.04 use systemd instead of Upstart?



      Someone please explain how this coexistence works.







      16.04 upstart services systemd sysv






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 20 '17 at 23:54









      wjandrea

      8,51142260




      8,51142260










      asked Jan 4 '17 at 9:00









      user2061057user2061057

      17316




      17316






















          1 Answer
          1






          active

          oldest

          votes


















          14














          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 systemd manages old "SysV" init scripts, see How does systemd use /etc/init.d scirpts?.



          Now, to answer the question about why it works to restart Network Manager with "service network-manager restart". The service command is used with both Upstart scripts and SysV init scripts, preferring the former. Network Manager also has an Upstart script installed on 16.04 at /etc/init/network-manager.conf.



          If you review the output of sudo strace service network-manager restart, you can get a sense of what's happening. First, the output shows that systemctl is being called, indicating that the command is being redirected to systemd. First, shortly after it opens /usr/bin/service, you can see it start to read in the file as a shell script:



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


          Now that we know that service is a shell script, we can go check out the source code of it. In the source code, we find that is_systemd is detected and set. For the systemd case, you can see that the command gets rewritten to be systemctl restart network-manager.



          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 systemctl tool to manage services.






          share|improve this answer

























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f867843%2fsysv-upstart-and-systemd-init-script-coexistence%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            14














            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 systemd manages old "SysV" init scripts, see How does systemd use /etc/init.d scirpts?.



            Now, to answer the question about why it works to restart Network Manager with "service network-manager restart". The service command is used with both Upstart scripts and SysV init scripts, preferring the former. Network Manager also has an Upstart script installed on 16.04 at /etc/init/network-manager.conf.



            If you review the output of sudo strace service network-manager restart, you can get a sense of what's happening. First, the output shows that systemctl is being called, indicating that the command is being redirected to systemd. First, shortly after it opens /usr/bin/service, you can see it start to read in the file as a shell script:



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


            Now that we know that service is a shell script, we can go check out the source code of it. In the source code, we find that is_systemd is detected and set. For the systemd case, you can see that the command gets rewritten to be systemctl restart network-manager.



            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 systemctl tool to manage services.






            share|improve this answer






























              14














              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 systemd manages old "SysV" init scripts, see How does systemd use /etc/init.d scirpts?.



              Now, to answer the question about why it works to restart Network Manager with "service network-manager restart". The service command is used with both Upstart scripts and SysV init scripts, preferring the former. Network Manager also has an Upstart script installed on 16.04 at /etc/init/network-manager.conf.



              If you review the output of sudo strace service network-manager restart, you can get a sense of what's happening. First, the output shows that systemctl is being called, indicating that the command is being redirected to systemd. First, shortly after it opens /usr/bin/service, you can see it start to read in the file as a shell script:



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


              Now that we know that service is a shell script, we can go check out the source code of it. In the source code, we find that is_systemd is detected and set. For the systemd case, you can see that the command gets rewritten to be systemctl restart network-manager.



              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 systemctl tool to manage services.






              share|improve this answer




























                14












                14








                14







                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 systemd manages old "SysV" init scripts, see How does systemd use /etc/init.d scirpts?.



                Now, to answer the question about why it works to restart Network Manager with "service network-manager restart". The service command is used with both Upstart scripts and SysV init scripts, preferring the former. Network Manager also has an Upstart script installed on 16.04 at /etc/init/network-manager.conf.



                If you review the output of sudo strace service network-manager restart, you can get a sense of what's happening. First, the output shows that systemctl is being called, indicating that the command is being redirected to systemd. First, shortly after it opens /usr/bin/service, you can see it start to read in the file as a shell script:



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


                Now that we know that service is a shell script, we can go check out the source code of it. In the source code, we find that is_systemd is detected and set. For the systemd case, you can see that the command gets rewritten to be systemctl restart network-manager.



                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 systemctl tool to manage services.






                share|improve this 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 systemd manages old "SysV" init scripts, see How does systemd use /etc/init.d scirpts?.



                Now, to answer the question about why it works to restart Network Manager with "service network-manager restart". The service command is used with both Upstart scripts and SysV init scripts, preferring the former. Network Manager also has an Upstart script installed on 16.04 at /etc/init/network-manager.conf.



                If you review the output of sudo strace service network-manager restart, you can get a sense of what's happening. First, the output shows that systemctl is being called, indicating that the command is being redirected to systemd. First, shortly after it opens /usr/bin/service, you can see it start to read in the file as a shell script:



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


                Now that we know that service is a shell script, we can go check out the source code of it. In the source code, we find that is_systemd is detected and set. For the systemd case, you can see that the command gets rewritten to be systemctl restart network-manager.



                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 systemctl tool to manage services.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Apr 13 '17 at 12:37









                Community

                1




                1










                answered Jan 4 '17 at 14:44









                Mark StosbergMark Stosberg

                2,19911526




                2,19911526






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f867843%2fsysv-upstart-and-systemd-init-script-coexistence%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Ellipse (mathématiques)

                    Quarter-circle Tiles

                    Mont Emei