[Armadillo.Tech ~]$

Linux: Autostart Scripts In Terminal Windows

There is lots of information on the internet on how to run scripts on login in Ubuntu. There is one issue with most of these methods, however! The scripts usually run invisibly in the background! There are plenty of cases where that is considered to be a good thing, but what if you want the startup scripts to run in nice terminal windows?

You could have Ubuntu’s Startup Applications tool run a .desktop file pointing to your script, but that’s not a great solution. If this file is deleted, your script won’t run! It’s bad enough that your script could be deleted, so why throw in another potential problem? The easiest way to handle this is to have the Startup Applications tool run a command that starts your script in a new terminal window. Unfortunately, things get very tricky here.

Something along the lines of gnome-terminal --command ./<yourscriptfile> is one of the common suggestions for starting a script in a new window. While that should actually work, it apparently does not in most cases. That might explain why nobody seems to have any luck with it. After doing a lot of digging, I found a variation of this command that works! It turns out that gnome-terminal --working-directory --command ./<yourscriptfile>; is the most reliable version of this elusive command. I have no idea why this information is so hard to find, but hopefully posting it here will make things easier for people!

A quick example:

Let’s say I want to start a script called script.bash from my Desktop directory in a new terminal window. The command for that would be gnome-terminal --working-directory ~/Desktop --command ./script.bash