I would like to run a sudo
command when Ubuntu starts up (before anyone logs in):
sudo searchd
How would I do this?
How to use systemd to run a command or script as root on boot. To use systemd to run a command or script as root when your computer boots, create a file (as root) called mycommand. service (replace mycommand with whatever you want to call it) in /etc/systemd/system/ .
Using crontab@reboot specifies that the script needs to be run at start up. You can use this method for almost every Linux distribution. That's it. As you can see it is very easy to add script to start up in Ubuntu.
You can add the command in the /etc/rc.local
script that is executed at the end of startup.
Write the command before exit 0
. Anything written after exit 0
will never be executed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With