Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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'm not sure if I'm phrasing the question correctly, but let's say that I have two virtual terminals open, and if I typed ls in one of them, I'd get the contents of the directory in both of them (the second one doesn't have to be writable, it only needs to display the stdout of the first one). How would I go about achieving this?

share|improve this question
up vote 8 down vote accepted

As geekosaur mentioned screen will do what you need (and much much much more).

First, create a named screen session for convenience in your first terminal:

$ screen -S foo

Second, attach to the screen session in your second terminal:

$ screen -x foo
share|improve this answer
Thanks. This expands on geekosaur's answer, and explains what I need to do, but all of them were helpful, so I thumbs up'd the rest. – Chris Blake Apr 7 '12 at 18:39

You can use script to do this.

For example, if you want to copy all your output to /dev/tty1 you would run

script -f /dev/tty1

From then on anything you type, and all command output will be duplicated on /dev/tty1.
script launches another shell, so when youre done, you can just type exit to end script.

The -f is to make it real-time. Othewise /dev/tty1 will only see the output when a complete line is displayed (when a newline char is written to the tty).

share|improve this answer

Depends on exactly what you're looking for. An easy solution is script(1); GNU screen in multiattach mode is a fancier solution.

share|improve this answer
script(1) isn't exactly what I'm looking for; I'm looking for something in real-time. How do I use screen in multi-attach mode? – Chris Blake Apr 6 '12 at 20:38
script will buffer output; depending on the implementation you can suppress this (on FreeBSD and Mac OS X, script -t 0), then tail -f typescript in the other window). With screen you want something like screen -S mysession in the first terminal and screen -x -r mysession in the second. – geekosaur Apr 6 '12 at 20:50

Your Answer


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.