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 three scripts I need to run when I start up my Ubuntu machine, they start services I use in my development environment.

To do that, I manually open three terminals and type in the commands.

Is there any way to create a script that will open three terminals and execute one command in each of these? (Each command should be in a separate terminal window so I can see their output).

share|improve this question
up vote 60 down vote accepted
gnome-terminal -e command


xterm -e command


konsole -e command

Pretty much

terminal -e command

To make the terminal stay when the command exits:

In konsole there is a --noclose flag.

In xterm, there is a -hold flag.

In gnome-terminal, go to Edit -> Profile Preferences -> Title. Click the Command tab. Select Hold the terminal from the drop-down menu labelled When command exits. You should create a new profile for that and execute with

gnome-terminal --window-with-profile=NAMEOFTHEPROFILE -e command
share|improve this answer

Instead of hard-coding gnome-terminal, konsole, et cetera, use the Alternatives system. The program that executes the default terminal emulator is:


On my system, it opens a new instance of Konsole every time I execute this command.

Luckily, the terminals seems to support the -e option for executing a command (I verified it for konsole and gnome-terminal). Arguments after the command are passed to the invoked command. Bash refuses to stay open in my terminal, an additional script is needed to get a terminal:

exec "$SHELL"

If you've saved the previous script as /home/user/hacky and made it executable, you would run your scripts with:

x-terminal-emulator -e /home/user/hacky your-script optional arguments here

The full path is required and /home/user/hacky has to be executable.

My previous attempt to run a script in a new terminal window can be found in revision #2, it was before I realised arguments can be passed to x-terminal-emulator.

share|improve this answer
In this case, it won't help much as the asker wants to do something that isn't the same for all terminals. – nickguletskii Jun 2 '11 at 20:36
Attempt #3: this one should keep the terminal open and run the program with optional arguments. – Lekensteyn Jun 2 '11 at 21:06
Ty for that x-terminal-emulator knowledge. That was what i was looking for. – prolink007 Oct 22 '12 at 19:55
I used gnome option, however, once I run my script, the main terminal closes !! .. any idea why ? – Suda.nese May 20 '15 at 14:33
@Suda.nese That is by design, when the "terminal" is done executing the script it will quit because there is nothing more to do. You could "fix" this by invoking a shell where you can execute commands (bash) or have a line such as read -p "Press Return to continue". – Lekensteyn May 20 '15 at 15:44

Quite simply-


/etc/init.d/ccpd status

This is enough for other commands that do not need to display anything in terminal. But here one has to see the status displayed.
So, it needs to run in a terminal window


gnome-terminal -e "/etc/init.d/ccpd status"  --window-with-profile=NAMEOFTHEPROFILE

The other post intended [] to be a placeholder

Here "NAMEOFTHEPROFILE" is to be replaced with the name of the profile that "Holds the terminal when the command exits".

enter image description here

enter image description here

share|improve this answer
@cipricus i believe [] was just placeholder – Karthik T Jan 23 '13 at 9:37
got it. but i have to make the terminal not to close so fast. i guess that is also in the linked question – cipricus Jan 23 '13 at 9:43
@cipricus have you tried the profile one? Just need to add --window-with-profile=NAMEOFTHEPROFILE to what I have given – Karthik T Jan 23 '13 at 9:44
@cipricus I would have to get back home to give better instructions, but the idea is to create a special profile with that option set, and use the name of the special profile in the place above. – Karthik T Jan 23 '13 at 9:51
@cipricus if that is enough for you, then that is ok. Profile is nothing more than a group of settings. You can setup the settings ONLY for use in your script, and not have to use it in all terminals. You can see Edit -> Profiles to see all the profiles you have, and you would add one there which was setup as explained in the post you linked – Karthik T Jan 23 '13 at 15:39

Use the screen command and -d detach from an existing screen session, and reattach here -m force a new screen session -S create a named session instead of using the default name

share|improve this answer

protected by Community Nov 25 '14 at 15:04

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.