Open terminal on startup and run command [duplicate]

Solution 1:

If you are using older GNOME you can add to startup something like this:

gnome-terminal --command "/path/myscript.sh"

Just edit your startup with gnome-session-properties GUI. It should be in System -> Properties menu or Applications –> Other –> Advanced Settings or press Alt+F2 and input it there. But apparently it was deprecated and it will not work on GNOME 3...

You can try adding into your folder ~/.config/autostart a file, let's say myscript.desktop with following content:

[Desktop Entry]
Type=Application
Exec=gnome-terminal --command "/path/myscript.sh"
Hidden=false
X-GNOME-Autostart-enabled=true
Name=Startup Script
Comment=

Above content is actually from my own system, created by mate-session-properties GUI and it works. Only updated it for GNOME. It actually might work on other environments, you'll just need to play with some details. Adding Terminal=true with Exec=/path/myscript.sh also works and with it you don't need to know the command to start your terminal.

On MATE it's easier, because it's still got that GUI. Commands are called mate-terminal and mate-session-properties. Here's how it looks on my MATE:

enter image description here

I'm not familiar with Elementary OS and you didn't say which desktop environment you are using (might be Pantheon which I've never worked on), but it should not be that different. You might need to figure out command to start your terminal and try running my-terminal --help or visit it's manpages to find proper parameter (or just try that much simpler Terminal=true solution).

And if for some reason Terminal=true doesn't work and you can't determine your terminal's commands, install XTerm:

sudo apt-get install xterm

Its command is xterm -e "/path/myscript.sh.