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;
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.
18.04 scripts
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.
add a comment
|
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.
18.04 scripts
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 "asroot
(the all-powerful user with$UID=0
)".sudo
is a tool for allowing a regular user to run a command asroot
. "at boot" - everything involved with system startup runs asroot
– 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 runningethtool
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
add a comment
|
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.
18.04 scripts
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
18.04 scripts
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 "asroot
(the all-powerful user with$UID=0
)".sudo
is a tool for allowing a regular user to run a command asroot
. "at boot" - everything involved with system startup runs asroot
– 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 runningethtool
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
add a comment
|
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 "asroot
(the all-powerful user with$UID=0
)".sudo
is a tool for allowing a regular user to run a command asroot
. "at boot" - everything involved with system startup runs asroot
– 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 runningethtool
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
add a comment
|
2 Answers
2
active
oldest
votes
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.
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
add a comment
|
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.
add a comment
|
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
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
add a comment
|
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.
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
add a comment
|
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.
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.
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
add a comment
|
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
add a comment
|
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.
add a comment
|
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.
add a comment
|
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.
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.
answered Jun 14 at 14:38
Willem VerminWillem Vermin
312 bronze badges
312 bronze badges
add a comment
|
add a comment
|
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 asroot
. "at boot" - everything involved with system startup runs asroot
– 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