Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a script in a folder:


I need this script to run every time the system starts (even if no one logs in to the system). What do I need to do in order to make this happen?

share|improve this question
possible duplicated: – Lucio Dec 12 '12 at 15:37
up vote 43 down vote accepted

You will need root privileges for any the following. To get root, open a terminal and run the command

sudo su

and the command prompt will change to '#' indicating that the terminal session has root privileges.

Alternative #1. Add an initscript.

Create a new script in /etc/init.d/myscript.

vi /etc/init.d/myscript

(Obviously it doesn't have to be called "myscript".) In this script, do whatever you want to do. Perhaps just run the script you mentioned.


Make it executable.

chmod ugo+x /etc/init.d/myscript

Configure the init system to run this script at startup.

update-rc.d myscript defaults

Alternative #2. Add commands to /etc/rc.local

vi /etc/rc.local

with content like the following.

# This script is executed at the end of each multiuser runlevel
/path/to/my/ || exit 1   # Added by me
exit 0

Alternative #3. Add an Upstart job.

Create /etc/init/myjob.conf

vi /etc/init/myjob.conf

with content like the following

description     "my job"
start on startup
exec /path/to/my/
share|improve this answer
Shouldn't people be using upstart now? – eduardocereto Dec 12 '12 at 15:14
Thanks. That is EXACTLY what I needed! – Rusty Dec 12 '12 at 15:22
It is possible to do the same thing by writing a short Upstart job. Initscripts are still supported, however, and are easy to use. – jdthood Dec 12 '12 at 15:50
Just added the Upstart-job method as a third alternative. – jdthood Dec 12 '12 at 15:58
You saved my life. :) – ihue Nov 3 '15 at 19:19

You don't need root, or to even login.

You can edit your crontab (crontab -e) and create an entry like this:

@reboot /path/to/

This way, you can run it as a regular user. @reboot just means it's run when the computer starts up (not necessarily just when it's rebooted).

share|improve this answer

In your home, you've a file named .bash_rc. This file is executed at the opening of your session.

Just put something like that at the end of the file :

sh /path/to/your/

EDIT: sorry, i didn't answer your question because my solution is executed when a user is logged in...

To execute something before the login, you can try rcconf or rc-file:

share|improve this answer
.bashrc is called when a new terminal is opened. – termnml Dec 12 '12 at 14:50
Thanks for the info. The website you mentioned has some good info! – Rusty Dec 12 '12 at 15:21

from terminal

  1. create file in ~/.config/autostart folder:

    gedit ~/.config/autostart/
  2. change Exec, Name and Comment value and add to file: first line

     [Desktop Entry]
     Comment=whatever you want
  3. save


you can do it from GUI:

  1. run "startup applications" tool in Ubuntu 14.04 you just write it in search box.
  2. add same Exec, Name and Comment.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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