On my office computer (running Scientific Linux 6.3) I have several windows running some processes in separate terminal emulators (/dev/pts/). I often connect to my office computer with iSSH from my iPad, but I can only see the results of the programs that have been written to a file and can't see what each terminal is showing or control the terminals.

I want to be able to temporarily switch control of a terminal to my iPad iSSH terminal, look at the results, run new commands (on my office terminal from my iPad) then let the program run on my office computer and return back to my iSSH terminal, so I can check other terminals or simply quit. Since I use 3G most of the time to connect with my iPad I don't want to use any graphically depenent method which will be very slow.

As far as I have understood, something like reptyr seems to permanently move control of a process from one terminal to another, I haven't seen any one talk (or ask) about giving control back to the original terminal. I want to return it back to it's original terminal after I finish.

I would really appreciate any suggestions or help. Thanks in advance

1 Answer 1


I believe you need just to run the original commands inside a screen session.

Then you can disconnect from it (screen keeps on running and keep your "virtual terminal" displayed correctly), and re-attach to it from another session (i.e., from your iPad, or from another computer, or from the same computer when you get back to it).

There are many more things screen can do too; for example, allow a co-worker to "sneak" to your running screen session as you use it, or when you are away from it, allowing to have several persons peeking at the same "terminal".

In a nutshell:

on your primary terminal, on host A, as user ORIGINALUSER:

command (ex: vi /tmp/file)
CTRL+a d # which is 'CTRL' and 'a' at the same time, and then 'd'. This will 'd'etach from the screen session, while screen itself still runs! (and inside it the commands, shell and any still running invoked command, still run)

on another terminal (or the same one) :

#log in the original machine (host A) as the same user ORIGINALUSER, and then:
screen -r   #will reattach to the latest running screen from that user. 

If there is more than one screen to reattach to, see the screen man page or on the net. Useful too if you can't reattach: there are ways to "force" it to reattach.

Once really finished: you just exit the shell running inside the screen. This will terminate the screen command too.

While in screen: ctrl+A is special, and allows you to send commands to screen. Try: ctrl+A ?

  • Thank you very much Olivier for your very complete reply. I will try the method at work tomorrow and write the result here. I am new to Linux and really excited at all the possibilites.
    – makhlaghi
    Commented Dec 26, 2012 at 16:52
  • @astroboy I'd recommend you to look at tmux also, it is like screen, but may be more comfortable for you to use (though it's a matter of taste). Commented Dec 26, 2012 at 22:29
  • I tried it out and it works great, thanks. I just had one more question. The processes that are running in the terminals are very CPU intensive. In fact that is the reason I separate them into different terminals to use as much of the CPU cores as possible. When I wrap all the processes into one process (screen or tmux) will that still let me use all my CPU cores?
    – makhlaghi
    Commented Dec 27, 2012 at 2:02
  • I tried it out with screen and it did divide the jobs through the different cores just as the different terminals do. Thank you very much, this will really help me in my future work.
    – makhlaghi
    Commented Dec 27, 2012 at 3:11
  • I'm glad it helped. But please send a thank you note to the developpers of GNU screen : that kind of random thank you note will boost their energy and will reward them for all the hard work they spent on creating it and making it available to everyone :) Commented Dec 27, 2012 at 11:07

You must log in to answer this question.

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