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

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












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




      10.7k31641










      asked Jun 18 '15 at 16:54









      S-K'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.






















          2 Answers
          2






          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










          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

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          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









          HBruijnHBruijn

          5,5261525




          5,5261525












          • 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









          dmouratidmourati

          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

















          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.




          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

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay