I have a .sh file that I execute just going to the containing folder and writing ./file.sh.

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?


  • 1
    Uhmm.. What do you mean by session? Opening terminal or gnome session? Dec 12, 2011 at 15:29
  • I mean after logging in Ubuntu.
    – tirenweb
    Dec 12, 2011 at 15:33
  • In this case follow tiempjuuh answer. Dec 12, 2011 at 15:38

5 Answers 5


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

enter image description here

enter image description here


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

# Start this awesome script
. /path/file.sh

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)

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.

  • If you put sh in front of the script (as in your example), it is not required to be executable.
    – enzotib
    Dec 12, 2011 at 16:57


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

[Desktop Entry]
Comment=auto start a sample 
Exec=startdesk.sh # app file name (default as bin/)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .