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 .sh file that I execute just going to the containing folder and writing ./

I want to execute that file when the session starts, so i create a symlink in /etc/init.d.

I expected it was executed when I start the session but it doesn't work..

The file has the "x" written next to the permissions, so I think it is executable.

Any help?


share|improve this question
Uhmm.. What do you mean by session? Opening terminal or gnome session? – Andrejs Cainikovs Dec 12 '11 at 15:29
I mean after logging in Ubuntu. – tirengarfio Dec 12 '11 at 15:33
In this case follow tiempjuuh answer. – Andrejs Cainikovs Dec 12 '11 at 15:38

Dash-->Startup Applications-->Add-->/path/to/your/.sh

enter image description here

enter image description here

share|improve this answer

/etc/init.d/ contains scripts that are being executed when system starts.
If you want to start every time you open a terminal, place a call to this script in your .bashrc file:

# Start this awesome script
. /path/
share|improve this answer

There are easily a billion ways to do this but starting where you have, to add something to the old init system you need to run the following:

sudo update-rc.d foo defaults

Where foo is your script name.

Some popular alternatives:

  • Edit /etc/rc.local to call your script before the exit.
  • Create an upstart script. This is the replacement for System-V init that Ubuntu has carried for the past few releases. It's fairly good if you want more control over when your script is called but it's a more work.
  • Launch it from within your X session (if this is a graphical machine) via gnome or another method (there are probably half a billion of these methods alone)
share|improve this answer

In the startup applications list add command below

sh <path to your file>.sh

make sure the file is marked as executable. i recommend to keep the file in home folder.

share|improve this answer
If you put sh in front of the script (as in your example), it is not required to be executable. – enzotib Dec 12 '11 at 16:57


~/.config/autostart/ --->Create a file (filename.desktop)
filename.desktop in file add:

[Desktop Entry]
Comment=auto start a sample 
# # app file name (default as bin/)
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.