I have made a .sh (which works) to run a mono program. How do I make it run every time I login? (and display in a terminal, not just run in background) Ubuntu server 12.04 with Unity desktop.

6 Answers 6

  • First make your script executable.
chmod +x /path/to/script
  • Open Startup Applications, from the cog menu present at the upper right corner.

Cog menu

  • Click on Add.

Startup Applications Dialog

  • Fill in all the details and click Add.

Add Startup Application Preferences

  • Logout and login back to check.

Yes you can start any script by navigating toSystem \ Preferences\ Sessions menu item and then just adding the command or the script you want to rin image

  • is this 12.04 ? it's unity in 12.04, not gnome 2
    – Prasad RD
    May 6, 2012 at 3:41
  • sorry, I meant unity.
    – jabelone
    May 6, 2012 at 3:50
  • ok sorry for i took it for gnome. Well unity has its own preferences. The startup application in unity can be found at topbar as a drop-down menu option of power button, located before the shotdown options and all.
    – ashutosh
    May 6, 2012 at 3:53

You could use $HOME/.bashrc It is parsed and run like a script, every time bash starts. Bash is the default shell for Ubuntu.

I have a script that saves every command line I've used, like this:

$ tail -2 $HOME/.bashrc
/usr/local/bin/backup-historial.sh &
  • So I have to put my scirpt in .bashrc which is in /home? I tried this and it didn't work.
    – jabelone
    May 6, 2012 at 4:10
  • bad idea for those who may ssh into a box
    – pcnate
    Oct 3, 2017 at 21:54

Go into the Startup Applications dialog, click Add, give it a name and in Command put

gnome-terminal -e yourscript.sh

You can check it works first by running gnome-terminal -e yourscript.sh from a terminal (it should then open another terminal).


Put your script in a file (we call it yourscript.sh) and make in executable:

#put your script here
echo "Press enter to close"
read line

Then open /etc/rc.local file using a text editor:

sudo gedit /etc/rc.local

Finally add the following code in the rc.local just before "exit 0" command:

gnome-terminal -e "./dirtoyourscript/yourscript.sh"

exit 0

Have a nice time.

  • I would believe, /etc/rc.local runs before X does (and thus, even before the login greeter); which means /etc/rc.local is not appropriate for doing things "after login".
    – sdaau
    May 4, 2013 at 20:54

if you kown how to handle crontab , add this line :

@reboot gnome-terminal -e "./dirtoyourscript/yourscript.sh"

if you don't know , execute the following commands to edit your crontab

export EDITOR
alias editor=$EDITOR
crontab -e

You must log in to answer this question.

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