Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How to run any command in another terminal window?

Example: I opened one terminal window and if I run command like apropos editor, then it run and out-puts on that window. But I want to run same command on another terminal window (new window) instead on present window from first terminal.

Further clarification:
I need suggest-command <command> that open new terminal window and run mentioned <command> in that (newly opened) window. (where suggest-command is example of suggestion of command.)

How to do that?

share|improve this question
    
Right-Click on the terminal icon and click on "Open New Terminal". –  Raphael Jun 18 at 12:08
    
Sorry if I sound like a lamen, but that's what I understood from your question. –  Raphael Jun 18 at 12:09
    
gnome-terminal right? –  Braiam Jun 18 at 14:19
    
While opening a new terminal may solve your problem, you might also wish to simply use nohup, re-direct the output, and put your editor in the background. nohup apropos editor &> /dev/null & –  bodhi.zazen Jun 18 at 15:27

4 Answers 4

up vote 3 down vote accepted

This might be what you search:

gnome-terminal -e "bash -c \"!!; exec bash\""

or (shortly):

gnome-terminal -x sh -c "!!; bash"

It opens gnome-terminal with your last command (!!) executed and it stays open with the command output in the shell, even with an interactive command like top or less...

In your case its:

gnome-terminal -e "bash -c \"apropos editor; exec bash\""

or

gnome-terminal -x sh -c "apropos editor; bash"
share|improve this answer
2  
A little bit shorter gnome-terminal -x sh -c "!!; bash" –  TuKsn Jun 18 at 13:22

Start another instance of whatever terminal is it you want to run:

xterm -hold -e 'apropos editor' & 

Note the -hold. Most terminals will exit after running the command you feed them. There are already a dozen or so questions about this on the site:

An alternative to that is to use an application which needs to be exited. nano will stay open on its own. If you're just outputting to screen, you could pipe it into less:

xterm -e 'apropos editor | less' & 

That said, in your case (as the other two have said) it does seem easier that you just open another terminal and run your command.

share|improve this answer
    
Can I use gnome-terminal instead of xterm then How to? –  Pandya Jun 18 at 12:23

You could use the -e option to gnome-terminal as follows:

gnome-terminal -e 'sh -c propose editor'

Here sh is the shell that gnome-terminal opens. Note that this will exit the terminal as soon as the command has terminated. Refer to the manual page for gnome-terminal for more.

share|improve this answer
    
How to hold new opened terminal, which is exiting after command finished/terminated? –  Pandya Jun 18 at 12:27

Each terminal is even a program that you can launch as any other program, with & to put in background, giving a list of arguments and so on.

Which terminal to use it depends first from the availability of the system that you are using (if they are installed or not), after from their peculiarity and then from your personal taste.

  konsole   --hold -e "ls" &  
  xterm      -hold -e "ls" &  
  gnome-terminal   -e "ls" & ...  

Note the differences between -hold of xterm and --hold of konsole.

Each realization has different options that you have to check with the help. Even the help can be invoked in different way. You can find that man konsole doesn't function and so you have to ask directly to the executable with --help.

This is a list of terminal you can search on your system

aterm          - AfterStep terminal with transparency support
gnome-terminal - default terminal for GNOME
guake          - A dropdown terminal for GNOME
konsole        - default terminal for KDE
Kuake          - a dropdown terminal for KDE
mrxvt          - Multi-tabbed rxvt clone
rxvt           - for the X Window System (and, in the form of a Cygwin port, 
                 for Windows) 
rxvt-unicode   - rxvt clone with unicode support
xfce4-terminal - default terminal for Xfce desktop 
                 environment with dropdown support
Terminator     - is a GPL terminal emulator. It is available on
                 Microsoft Windows, Mac OS X, Linux and other Unix X11 systems.
Terminology    - enhanced terminal supportive of multimedia 
                 and text manipulation for X11 and Linux framebuffer
tilda          - A drop down terminal
wterm          - It is a fork of rxvt, designed to be lightweight, but still
                 full of features
xterm          - default terminal for the X Window System
Yakuake        - (Yet Another Kuake), a dropdown terminal for KDE
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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