Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ubuntu - Run command on start-up with "sudo"

I would like to run a sudo command when Ubuntu starts up (before anyone logs in):

sudo searchd 

How would I do this?

like image 716
Mark Willis Avatar asked Mar 13 '12 11:03

Mark Willis


People also ask

How do I run a script as root on startup?

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

How do I run a shell script on startup Ubuntu?

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.


1 Answers

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.

like image 131
Didier Trosset Avatar answered Oct 03 '22 05:10

Didier Trosset