What user runs the commands defined in /etc/rc.local?












9














Are the commands in /etc/rc.local ran by su by default?

Do I need to specific sudo before each command or will they be ran by su regardless?










share|improve this question















migrated from serverfault.com Jun 20 '15 at 3:26


This question came from our site for system and network administrators.




















    9














    Are the commands in /etc/rc.local ran by su by default?

    Do I need to specific sudo before each command or will they be ran by su regardless?










    share|improve this question















    migrated from serverfault.com Jun 20 '15 at 3:26


    This question came from our site for system and network administrators.


















      9












      9








      9


      3





      Are the commands in /etc/rc.local ran by su by default?

      Do I need to specific sudo before each command or will they be ran by su regardless?










      share|improve this question















      Are the commands in /etc/rc.local ran by su by default?

      Do I need to specific sudo before each command or will they be ran by su regardless?







      linux sudo startup su






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 5 '18 at 15:16









      schily

      10.6k31641




      10.6k31641










      asked Jun 18 '15 at 16:54









      S-K'

      148114




      148114




      migrated from serverfault.com Jun 20 '15 at 3:26


      This question came from our site for system and network administrators.






      migrated from serverfault.com Jun 20 '15 at 3:26


      This question came from our site for system and network administrators.
























          3 Answers
          3






          active

          oldest

          votes


















          14














          su is not a user it's program to run subsequent commands/programs under an alternate identity of another user than the one executing the command. It is very similar to sudo in that regard.



          Unless another user is specified both commands will default to running the command under the alternate identity of the root user, the superuser/administrator.



          The main difference between su and sudo is that:





          • su requires you to know the password of that alternate user, where


          • sudo will prompt for the password of the user running the sudo command and requires setup so that the user is allowed to run the requested commands/programs.


          (When root runs either su or sudo no password is required.)





          Like any init script, the /etc/rc.local script is executed by the root user and you do not need to prepend either su or sudo to the commands/programs that need to run as root.



          You may still need to use su or sudo in your init scripts if those commands need to be executed not as root but another user/service-account...



          su -oracle/do/something/as/oracle/user






          share|improve this answer





















          • What do I do if I put su - user /path/to/script.sh in rc.local, and when sourcing it it prompts me for the user password (and closes the terminal afterwards). How do I make it not ask me for the user's password?
            – alonso s
            Jan 3 '18 at 1:40



















          9














          Yes, all the scripts and programs are directly called by root.



          The /etc/rc.local file is called directly by the init process.






          share|improve this answer





















          • So then, we didn't need to add sudo before commands in /etc/rc.local?
            – Benyamin Jafari
            Jun 5 '18 at 14:59



















          0














          Im not sure what im missing but hoping for some help. I need to run this command line at startup
          echo 1 > /sys/module/bluetooth/parameters/disable_ertm
          when I go to terminal type SU enter my password type that command it works perfectly, yet when i add that line the /etc/rc.local
          echo 1 > /sys/module/bluetooth/parameters/disable_ertm before the exit 0 it does nothing at all....






          share|improve this answer








          New contributor




          Steve is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.


















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "106"
            };
            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: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            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%2funix.stackexchange.com%2fquestions%2f210939%2fwhat-user-runs-the-commands-defined-in-etc-rc-local%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            14














            su is not a user it's program to run subsequent commands/programs under an alternate identity of another user than the one executing the command. It is very similar to sudo in that regard.



            Unless another user is specified both commands will default to running the command under the alternate identity of the root user, the superuser/administrator.



            The main difference between su and sudo is that:





            • su requires you to know the password of that alternate user, where


            • sudo will prompt for the password of the user running the sudo command and requires setup so that the user is allowed to run the requested commands/programs.


            (When root runs either su or sudo no password is required.)





            Like any init script, the /etc/rc.local script is executed by the root user and you do not need to prepend either su or sudo to the commands/programs that need to run as root.



            You may still need to use su or sudo in your init scripts if those commands need to be executed not as root but another user/service-account...



            su -oracle/do/something/as/oracle/user






            share|improve this answer





















            • What do I do if I put su - user /path/to/script.sh in rc.local, and when sourcing it it prompts me for the user password (and closes the terminal afterwards). How do I make it not ask me for the user's password?
              – alonso s
              Jan 3 '18 at 1:40
















            14














            su is not a user it's program to run subsequent commands/programs under an alternate identity of another user than the one executing the command. It is very similar to sudo in that regard.



            Unless another user is specified both commands will default to running the command under the alternate identity of the root user, the superuser/administrator.



            The main difference between su and sudo is that:





            • su requires you to know the password of that alternate user, where


            • sudo will prompt for the password of the user running the sudo command and requires setup so that the user is allowed to run the requested commands/programs.


            (When root runs either su or sudo no password is required.)





            Like any init script, the /etc/rc.local script is executed by the root user and you do not need to prepend either su or sudo to the commands/programs that need to run as root.



            You may still need to use su or sudo in your init scripts if those commands need to be executed not as root but another user/service-account...



            su -oracle/do/something/as/oracle/user






            share|improve this answer





















            • What do I do if I put su - user /path/to/script.sh in rc.local, and when sourcing it it prompts me for the user password (and closes the terminal afterwards). How do I make it not ask me for the user's password?
              – alonso s
              Jan 3 '18 at 1:40














            14












            14








            14






            su is not a user it's program to run subsequent commands/programs under an alternate identity of another user than the one executing the command. It is very similar to sudo in that regard.



            Unless another user is specified both commands will default to running the command under the alternate identity of the root user, the superuser/administrator.



            The main difference between su and sudo is that:





            • su requires you to know the password of that alternate user, where


            • sudo will prompt for the password of the user running the sudo command and requires setup so that the user is allowed to run the requested commands/programs.


            (When root runs either su or sudo no password is required.)





            Like any init script, the /etc/rc.local script is executed by the root user and you do not need to prepend either su or sudo to the commands/programs that need to run as root.



            You may still need to use su or sudo in your init scripts if those commands need to be executed not as root but another user/service-account...



            su -oracle/do/something/as/oracle/user






            share|improve this answer












            su is not a user it's program to run subsequent commands/programs under an alternate identity of another user than the one executing the command. It is very similar to sudo in that regard.



            Unless another user is specified both commands will default to running the command under the alternate identity of the root user, the superuser/administrator.



            The main difference between su and sudo is that:





            • su requires you to know the password of that alternate user, where


            • sudo will prompt for the password of the user running the sudo command and requires setup so that the user is allowed to run the requested commands/programs.


            (When root runs either su or sudo no password is required.)





            Like any init script, the /etc/rc.local script is executed by the root user and you do not need to prepend either su or sudo to the commands/programs that need to run as root.



            You may still need to use su or sudo in your init scripts if those commands need to be executed not as root but another user/service-account...



            su -oracle/do/something/as/oracle/user







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jun 19 '15 at 7:31









            HBruijn

            5,5061525




            5,5061525












            • What do I do if I put su - user /path/to/script.sh in rc.local, and when sourcing it it prompts me for the user password (and closes the terminal afterwards). How do I make it not ask me for the user's password?
              – alonso s
              Jan 3 '18 at 1:40


















            • What do I do if I put su - user /path/to/script.sh in rc.local, and when sourcing it it prompts me for the user password (and closes the terminal afterwards). How do I make it not ask me for the user's password?
              – alonso s
              Jan 3 '18 at 1:40
















            What do I do if I put su - user /path/to/script.sh in rc.local, and when sourcing it it prompts me for the user password (and closes the terminal afterwards). How do I make it not ask me for the user's password?
            – alonso s
            Jan 3 '18 at 1:40




            What do I do if I put su - user /path/to/script.sh in rc.local, and when sourcing it it prompts me for the user password (and closes the terminal afterwards). How do I make it not ask me for the user's password?
            – alonso s
            Jan 3 '18 at 1:40













            9














            Yes, all the scripts and programs are directly called by root.



            The /etc/rc.local file is called directly by the init process.






            share|improve this answer





















            • So then, we didn't need to add sudo before commands in /etc/rc.local?
              – Benyamin Jafari
              Jun 5 '18 at 14:59
















            9














            Yes, all the scripts and programs are directly called by root.



            The /etc/rc.local file is called directly by the init process.






            share|improve this answer





















            • So then, we didn't need to add sudo before commands in /etc/rc.local?
              – Benyamin Jafari
              Jun 5 '18 at 14:59














            9












            9








            9






            Yes, all the scripts and programs are directly called by root.



            The /etc/rc.local file is called directly by the init process.






            share|improve this answer












            Yes, all the scripts and programs are directly called by root.



            The /etc/rc.local file is called directly by the init process.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jun 18 '15 at 16:58









            dmourati

            23613




            23613












            • So then, we didn't need to add sudo before commands in /etc/rc.local?
              – Benyamin Jafari
              Jun 5 '18 at 14:59


















            • So then, we didn't need to add sudo before commands in /etc/rc.local?
              – Benyamin Jafari
              Jun 5 '18 at 14:59
















            So then, we didn't need to add sudo before commands in /etc/rc.local?
            – Benyamin Jafari
            Jun 5 '18 at 14:59




            So then, we didn't need to add sudo before commands in /etc/rc.local?
            – Benyamin Jafari
            Jun 5 '18 at 14:59











            0














            Im not sure what im missing but hoping for some help. I need to run this command line at startup
            echo 1 > /sys/module/bluetooth/parameters/disable_ertm
            when I go to terminal type SU enter my password type that command it works perfectly, yet when i add that line the /etc/rc.local
            echo 1 > /sys/module/bluetooth/parameters/disable_ertm before the exit 0 it does nothing at all....






            share|improve this answer








            New contributor




            Steve is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.























              0














              Im not sure what im missing but hoping for some help. I need to run this command line at startup
              echo 1 > /sys/module/bluetooth/parameters/disable_ertm
              when I go to terminal type SU enter my password type that command it works perfectly, yet when i add that line the /etc/rc.local
              echo 1 > /sys/module/bluetooth/parameters/disable_ertm before the exit 0 it does nothing at all....






              share|improve this answer








              New contributor




              Steve is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.





















                0












                0








                0






                Im not sure what im missing but hoping for some help. I need to run this command line at startup
                echo 1 > /sys/module/bluetooth/parameters/disable_ertm
                when I go to terminal type SU enter my password type that command it works perfectly, yet when i add that line the /etc/rc.local
                echo 1 > /sys/module/bluetooth/parameters/disable_ertm before the exit 0 it does nothing at all....






                share|improve this answer








                New contributor




                Steve is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                Im not sure what im missing but hoping for some help. I need to run this command line at startup
                echo 1 > /sys/module/bluetooth/parameters/disable_ertm
                when I go to terminal type SU enter my password type that command it works perfectly, yet when i add that line the /etc/rc.local
                echo 1 > /sys/module/bluetooth/parameters/disable_ertm before the exit 0 it does nothing at all....







                share|improve this answer








                New contributor




                Steve is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                share|improve this answer



                share|improve this answer






                New contributor




                Steve is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                answered 28 mins ago









                Steve

                1




                1




                New contributor




                Steve is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.





                New contributor





                Steve is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






                Steve is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • 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.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • 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%2funix.stackexchange.com%2fquestions%2f210939%2fwhat-user-runs-the-commands-defined-in-etc-rc-local%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

                    Entries order in /etc/network/interfaces

                    新発田市

                    Grub takes very long (several minutes) to open Menu (in Multi-Boot-System)