Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

This question already has an answer here:

I want to run a command on startup on my Ubuntu Server. Does anyone know how to do this? Does /etc/rc.local run as superuser? Any help will be appreciated. Thanks!

share|improve this question

marked as duplicate by Jacob Vlijm, karel, Eric Carvalho, David Foerster, mikewhatever Jun 3 at 17:41

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.

2 Answers 2

up vote 3 down vote accepted

/etc/rc.local will run as root.

Most of the init process is run as root, or starts out that way.

share|improve this answer

There's a couple of places you can do this:

/etc/init.d (and then making a link to /etc/rc[runlevel].d - usually 2) works pretty well - so you can specify start up and shut down bits in there.

That's kind of an old way (though oh so very easy). You can also do something with upstart. Look at this page (look at the "Writing Jobs" section).

The big gotcha - the path is normally not quite what you'd expect. So I'd suggest running something along the lines of "echo $PATH > /init_path" from whatever script first to see if you might have an issue (check /init_path and see what's in there.. perfectly safe to remove this file). While it's easy to specify paths in your script, it's worth setting the PATH variable accordingly as anything run from whatever script may also need things in PATH.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.