To have one terminal window mirror the contents of another, first start a screen session in one of them. screen effectively allows you to create a command-line login that's independent of any actual terminal windows or virtual consoles (so if the terminal window quits, the command-line login will still be running in the background). To start it, simply type screen. Then open another terminal window and attach to the currently running screen session by typing screen -x. Now try typing something to see what the effect is.
To detach from the screen session, in either or both terminal windows, type [Ctrl ]+[^ and then hit [d). Note that if you detach in both terminal windows, the screen session will still be running in the background. To quit it, you must reattach to it (type screen -r), and hit [Ctrl ]+d (or just type exit at the prompt).
This trick works in a virtual console too—you could start a screen session in a terminal window and have it mirrored at a virtual console prompt by attaching to it using screen -x.
By combining this tip with an SSH remote connection (see Tip 190, on page 228), you can not only create a command-login using screen that will persist on the remote computer even if the SSH connection is lost (useful if running commands that take some time to complete, or if you're using a flaky connection), but you can create a setup whereby what you type is mirrored on the remote computer in a terminal window— just ask the user sitting in front of the remote computer to open a terminal window and type screen -x, once you've started screen in the SSH session. This provides an excellent way of remote teaching.
Was this article helpful?