How do I run a script as sudo at boot time on Ubuntu 18.04 Server? [duplicate]How to run a script during boot as rootHow to run a script during boot as rootOne time “firmware” upgrade scriptRun script on login (script with sudo) or startupProblem when run script in bootRunning a python script from my php serverCannot run bash script permission deniedvncserver won't run in a shell script executed with sudoAllow a shell script containing sudo to run

Is SSH key with passphrase a 2FA

how can I enforce the prohibition on love potions?

What is the speed of "electricity"?

What clothing should I bring to Mt. Titlis in Switzerland during December?

How are side-channel attacks executed? What does an attacker need to execute a side channel attack?

Do dead weight 'components' exist?

How exactly do you avoid fooling yourself?

What is the type of English used in the King James Bible called?

Promotions usually come with raises, right?

What would an inclusive curriculum look like in a computer science course?

"The" for the first time only

Fast symmetric key cryptography class

If someone orders a pizza in the US and doesn't pay for it, could they be arrested?

How could Thanos survive this attack?

How to persuade players not to cheat?

How can you castle legally in Chess960 when the castling rook is on the king's destination square?

Is (manual) feature extraction outdated?

Locked out of my own server

Does the original Game Boy game "Tetris" have a battery memory inside the cartridge?

How does Deep Packet Inspection work with encrypted packets?

Creating cryptographic algorithms at runtime

Log user out after change of IP address?

Why is the air inside airliners so dry (low humidity)?

Why the real and imaginary parts of a complex analytic function are not independent?



How do I run a script as sudo at boot time on Ubuntu 18.04 Server? [duplicate]


How to run a script during boot as rootHow to run a script during boot as rootOne time “firmware” upgrade scriptRun script on login (script with sudo) or startupProblem when run script in bootRunning a python script from my php serverCannot run bash script permission deniedvncserver won't run in a shell script executed with sudoAllow a shell script containing sudo to run






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









9


















This question already has an answer here:



  • How to run a script during boot as root

    7 answers



How do I run a script as sudo at boot time?



I need to run ethtool --offload <net> rx off to disable the annoying jme udp checksum error message.










share|improve this question


















marked as duplicate by Fabby, karel, Kulfy, Elder Geek, Eliah Kagan Jul 6 at 19:45


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • why do you believe you would need sudo at boot time?

    – Rinzwind
    Jun 14 at 14:39











  • @Rinzwind probably because ethtool needs root to run. SystemD unit as root is the best approach

    – Thomas Ward
    Jun 14 at 14:52






  • 1





    "as sudo" - you mean "as root (the all-powerful user with $UID=0)". sudo is a tool for allowing a regular user to run a command as root. "at boot" - everything involved with system startup runs as root

    – waltinator
    Jun 14 at 17:45











  • @waltinator: except things that drop privileges; e.g. you can have your system start up an X server + user session for a certain user. But running ethtool via sudo from something that had dropped privileges (like the wording of this question suggest) would be a really bad idea vs. sticking it in /etc/rc.local or any more "modern" way to get things run as root during boot.

    – Peter Cordes
    Jun 15 at 2:41

















9


















This question already has an answer here:



  • How to run a script during boot as root

    7 answers



How do I run a script as sudo at boot time?



I need to run ethtool --offload <net> rx off to disable the annoying jme udp checksum error message.










share|improve this question


















marked as duplicate by Fabby, karel, Kulfy, Elder Geek, Eliah Kagan Jul 6 at 19:45


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • why do you believe you would need sudo at boot time?

    – Rinzwind
    Jun 14 at 14:39











  • @Rinzwind probably because ethtool needs root to run. SystemD unit as root is the best approach

    – Thomas Ward
    Jun 14 at 14:52






  • 1





    "as sudo" - you mean "as root (the all-powerful user with $UID=0)". sudo is a tool for allowing a regular user to run a command as root. "at boot" - everything involved with system startup runs as root

    – waltinator
    Jun 14 at 17:45











  • @waltinator: except things that drop privileges; e.g. you can have your system start up an X server + user session for a certain user. But running ethtool via sudo from something that had dropped privileges (like the wording of this question suggest) would be a really bad idea vs. sticking it in /etc/rc.local or any more "modern" way to get things run as root during boot.

    – Peter Cordes
    Jun 15 at 2:41













9












9








9


1







This question already has an answer here:



  • How to run a script during boot as root

    7 answers



How do I run a script as sudo at boot time?



I need to run ethtool --offload <net> rx off to disable the annoying jme udp checksum error message.










share|improve this question


















This question already has an answer here:



  • How to run a script during boot as root

    7 answers



How do I run a script as sudo at boot time?



I need to run ethtool --offload <net> rx off to disable the annoying jme udp checksum error message.





This question already has an answer here:



  • How to run a script during boot as root

    7 answers







18.04 scripts






share|improve this question
















share|improve this question













share|improve this question




share|improve this question








edited Jun 14 at 14:33









SurvivalMachine

2,0185 gold badges12 silver badges24 bronze badges




2,0185 gold badges12 silver badges24 bronze badges










asked Jun 14 at 14:06









Amie NelAmie Nel

462 bronze badges




462 bronze badges





marked as duplicate by Fabby, karel, Kulfy, Elder Geek, Eliah Kagan Jul 6 at 19:45


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











marked as duplicate by Fabby, karel, Kulfy, Elder Geek, Eliah Kagan Jul 6 at 19:45


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Fabby, karel, Kulfy, Elder Geek, Eliah Kagan Jul 6 at 19:45


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • why do you believe you would need sudo at boot time?

    – Rinzwind
    Jun 14 at 14:39











  • @Rinzwind probably because ethtool needs root to run. SystemD unit as root is the best approach

    – Thomas Ward
    Jun 14 at 14:52






  • 1





    "as sudo" - you mean "as root (the all-powerful user with $UID=0)". sudo is a tool for allowing a regular user to run a command as root. "at boot" - everything involved with system startup runs as root

    – waltinator
    Jun 14 at 17:45











  • @waltinator: except things that drop privileges; e.g. you can have your system start up an X server + user session for a certain user. But running ethtool via sudo from something that had dropped privileges (like the wording of this question suggest) would be a really bad idea vs. sticking it in /etc/rc.local or any more "modern" way to get things run as root during boot.

    – Peter Cordes
    Jun 15 at 2:41

















  • why do you believe you would need sudo at boot time?

    – Rinzwind
    Jun 14 at 14:39











  • @Rinzwind probably because ethtool needs root to run. SystemD unit as root is the best approach

    – Thomas Ward
    Jun 14 at 14:52






  • 1





    "as sudo" - you mean "as root (the all-powerful user with $UID=0)". sudo is a tool for allowing a regular user to run a command as root. "at boot" - everything involved with system startup runs as root

    – waltinator
    Jun 14 at 17:45











  • @waltinator: except things that drop privileges; e.g. you can have your system start up an X server + user session for a certain user. But running ethtool via sudo from something that had dropped privileges (like the wording of this question suggest) would be a really bad idea vs. sticking it in /etc/rc.local or any more "modern" way to get things run as root during boot.

    – Peter Cordes
    Jun 15 at 2:41
















why do you believe you would need sudo at boot time?

– Rinzwind
Jun 14 at 14:39





why do you believe you would need sudo at boot time?

– Rinzwind
Jun 14 at 14:39













@Rinzwind probably because ethtool needs root to run. SystemD unit as root is the best approach

– Thomas Ward
Jun 14 at 14:52





@Rinzwind probably because ethtool needs root to run. SystemD unit as root is the best approach

– Thomas Ward
Jun 14 at 14:52




1




1





"as sudo" - you mean "as root (the all-powerful user with $UID=0)". sudo is a tool for allowing a regular user to run a command as root. "at boot" - everything involved with system startup runs as root

– waltinator
Jun 14 at 17:45





"as sudo" - you mean "as root (the all-powerful user with $UID=0)". sudo is a tool for allowing a regular user to run a command as root. "at boot" - everything involved with system startup runs as root

– waltinator
Jun 14 at 17:45













@waltinator: except things that drop privileges; e.g. you can have your system start up an X server + user session for a certain user. But running ethtool via sudo from something that had dropped privileges (like the wording of this question suggest) would be a really bad idea vs. sticking it in /etc/rc.local or any more "modern" way to get things run as root during boot.

– Peter Cordes
Jun 15 at 2:41





@waltinator: except things that drop privileges; e.g. you can have your system start up an X server + user session for a certain user. But running ethtool via sudo from something that had dropped privileges (like the wording of this question suggest) would be a really bad idea vs. sticking it in /etc/rc.local or any more "modern" way to get things run as root during boot.

– Peter Cordes
Jun 15 at 2:41










2 Answers
2






active

oldest

votes


















10


















You can create a systemd service.



Create a file /etc/systemd/system/ethtool.service:



[Unit]
Description=ethtool script

[Service]
ExecStart=/path/to/yourscript.sh

[Install]
WantedBy=multi-user.target


And script /path/to/yourscript.sh (don't forget to chmod +x it)



#!/bin/bash
ethtool --offload <net> rx off


Enable your service



systemctl enable ethtool


It will run on boot as root.






share|improve this answer





















  • 1





    Thanks, this worked for me

    – Amie Nel
    Jun 14 at 15:01






  • 1





    If @deimos excellent answer was helpful, please accept it: askubuntu.com/tour The searchers will appreciate knowing that the answer works as expected.

    – chili555
    Jun 14 at 20:40


















1


















Put your commands in /etc/rc.local
or create that file if it does not exist:



 touch /etc/rc.local
chmod +x /etc/rc.local


All these actions have to be done as root.






share|improve this answer

































    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    10


















    You can create a systemd service.



    Create a file /etc/systemd/system/ethtool.service:



    [Unit]
    Description=ethtool script

    [Service]
    ExecStart=/path/to/yourscript.sh

    [Install]
    WantedBy=multi-user.target


    And script /path/to/yourscript.sh (don't forget to chmod +x it)



    #!/bin/bash
    ethtool --offload <net> rx off


    Enable your service



    systemctl enable ethtool


    It will run on boot as root.






    share|improve this answer





















    • 1





      Thanks, this worked for me

      – Amie Nel
      Jun 14 at 15:01






    • 1





      If @deimos excellent answer was helpful, please accept it: askubuntu.com/tour The searchers will appreciate knowing that the answer works as expected.

      – chili555
      Jun 14 at 20:40















    10


















    You can create a systemd service.



    Create a file /etc/systemd/system/ethtool.service:



    [Unit]
    Description=ethtool script

    [Service]
    ExecStart=/path/to/yourscript.sh

    [Install]
    WantedBy=multi-user.target


    And script /path/to/yourscript.sh (don't forget to chmod +x it)



    #!/bin/bash
    ethtool --offload <net> rx off


    Enable your service



    systemctl enable ethtool


    It will run on boot as root.






    share|improve this answer





















    • 1





      Thanks, this worked for me

      – Amie Nel
      Jun 14 at 15:01






    • 1





      If @deimos excellent answer was helpful, please accept it: askubuntu.com/tour The searchers will appreciate knowing that the answer works as expected.

      – chili555
      Jun 14 at 20:40













    10














    10










    10









    You can create a systemd service.



    Create a file /etc/systemd/system/ethtool.service:



    [Unit]
    Description=ethtool script

    [Service]
    ExecStart=/path/to/yourscript.sh

    [Install]
    WantedBy=multi-user.target


    And script /path/to/yourscript.sh (don't forget to chmod +x it)



    #!/bin/bash
    ethtool --offload <net> rx off


    Enable your service



    systemctl enable ethtool


    It will run on boot as root.






    share|improve this answer














    You can create a systemd service.



    Create a file /etc/systemd/system/ethtool.service:



    [Unit]
    Description=ethtool script

    [Service]
    ExecStart=/path/to/yourscript.sh

    [Install]
    WantedBy=multi-user.target


    And script /path/to/yourscript.sh (don't forget to chmod +x it)



    #!/bin/bash
    ethtool --offload <net> rx off


    Enable your service



    systemctl enable ethtool


    It will run on boot as root.







    share|improve this answer













    share|improve this answer




    share|improve this answer










    answered Jun 14 at 14:46









    deimosdeimos

    2911 silver badge8 bronze badges




    2911 silver badge8 bronze badges










    • 1





      Thanks, this worked for me

      – Amie Nel
      Jun 14 at 15:01






    • 1





      If @deimos excellent answer was helpful, please accept it: askubuntu.com/tour The searchers will appreciate knowing that the answer works as expected.

      – chili555
      Jun 14 at 20:40












    • 1





      Thanks, this worked for me

      – Amie Nel
      Jun 14 at 15:01






    • 1





      If @deimos excellent answer was helpful, please accept it: askubuntu.com/tour The searchers will appreciate knowing that the answer works as expected.

      – chili555
      Jun 14 at 20:40







    1




    1





    Thanks, this worked for me

    – Amie Nel
    Jun 14 at 15:01





    Thanks, this worked for me

    – Amie Nel
    Jun 14 at 15:01




    1




    1





    If @deimos excellent answer was helpful, please accept it: askubuntu.com/tour The searchers will appreciate knowing that the answer works as expected.

    – chili555
    Jun 14 at 20:40





    If @deimos excellent answer was helpful, please accept it: askubuntu.com/tour The searchers will appreciate knowing that the answer works as expected.

    – chili555
    Jun 14 at 20:40













    1


















    Put your commands in /etc/rc.local
    or create that file if it does not exist:



     touch /etc/rc.local
    chmod +x /etc/rc.local


    All these actions have to be done as root.






    share|improve this answer






























      1


















      Put your commands in /etc/rc.local
      or create that file if it does not exist:



       touch /etc/rc.local
      chmod +x /etc/rc.local


      All these actions have to be done as root.






      share|improve this answer




























        1














        1










        1









        Put your commands in /etc/rc.local
        or create that file if it does not exist:



         touch /etc/rc.local
        chmod +x /etc/rc.local


        All these actions have to be done as root.






        share|improve this answer














        Put your commands in /etc/rc.local
        or create that file if it does not exist:



         touch /etc/rc.local
        chmod +x /etc/rc.local


        All these actions have to be done as root.







        share|improve this answer













        share|improve this answer




        share|improve this answer










        answered Jun 14 at 14:38









        Willem VerminWillem Vermin

        312 bronze badges




        312 bronze badges
















            Popular posts from this blog

            Tamil (spriik) Luke uk diar | Nawigatjuun

            Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

            Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?