I am just fooling around on my terminal (Gnome terminal). I was wondering is there a way to send output of one terminal to another without having to make a new file or pipe.

for example: on first terminal I run ls and want its output to be displayed on second terminal (with or without using any command on second)

  • what do you have? Did you try something? Can you give some examples?
    – tachomi
    Feb 11, 2016 at 14:53
  • @tachomi on first terminal I run ls and want its output to be displayed on second terminal (with or without using any command on second)
    – Alex Jones
    Feb 11, 2016 at 14:55

5 Answers 5


If both terminals belong to the same user, you can send your output to the virtual device that is used as the particular terminal's tty.

So you can use the output from w, which includes the TTY information, and write directly to that device.

ls > /dev/pts/7

(If the device mentioned by w was pts/7)

Another option is to use the number of a process that is connected to that device. Send your output to /proc/<process number>/fd/1.

ls > /proc/5555/fd/1

Assuming the process number that you found that runs in that terminal is 5555.

Note that this direct write is only allowed if the user that attempts to write is the same user that owns the other terminal.

  • 1
    I dont get /dev/pts/7 or similar with w command, but second way works for me
    – Alex Jones
    Feb 11, 2016 at 15:07
  • 3
    @edwardtorvalds The /proc/XXX/fd/1 is generally a soft link to the base device. Try using ls -l /proc/XXXX/fd/1 and see what it is pointing to. Does it have any relation to what appeared in the w command? Feb 11, 2016 at 15:22
  • I am not relating w command with /proc/XXX/fd/0 I am relating w command with /dev/pts/7
    – Alex Jones
    Feb 11, 2016 at 15:26
  • 4
    @edwardtorvalds I am saying that they are connected as /proc/XXX/fd/1 is supposed to be a soft link to whatever device the w command displays. What is the output of ls -l on it? Feb 11, 2016 at 15:27
  • 1
    TTY information can also be found in the output from tty (only current) or who (all). Mar 3, 2016 at 5:53

You can use write command.

As @MelBurslan commented, if write permission is off, first execute:

 $ mesg y

From man mesg


y Allow write access to your terminal.

Usage of write:

$ write username tty

e.g. Send ls output to other terminal.

$ w
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
user     :0       :0               08:15   ?xdm?   7:37   0.25s init --user
user     pts/0    :0               08:19    1.00s  0.09s  0.01s w
user     pts/12   :0               08:50   54.00s  0.03s  0.03s bash

$ ls | write username pts/12
  • on arch linux, in gnome terminal, output of w command is edward tty2 19:53 6:05 2:48 23.12s firefox and if I write ls | write edward tty2 I get no output but a beep sound
    – Alex Jones
    Feb 11, 2016 at 15:00
  • also if I try it on tty5 (ctrl + alt + 5) I get error you have turned write permission off
    – Alex Jones
    Feb 11, 2016 at 15:04
  • that was typing error on this site
    – Alex Jones
    Feb 11, 2016 at 15:04
  • try mesg y command on the target terminal, before you run the command
    – MelBurslan
    Feb 11, 2016 at 15:07
  • @tachomi mesg y makes it work, please include it in your answer
    – Alex Jones
    Feb 11, 2016 at 15:09

I found a similar method.

On first terminal:

 $ tty
 $ <no need to run any command here, just see the output>

On second terminal:

$ ls > /dev/pts/0

Now you get the output on first terminal

  • 1
    tail -f instead of cat could be useful
    – tachomi
    Feb 11, 2016 at 15:37
  • 3
    @tachomi actually there is no need of any command to read the output
    – Alex Jones
    Feb 11, 2016 at 17:37

you can write to the terminal's TTY; for example:

in terminal 1:

$ tty 

in terminal 2:

$ tty

$ exec &> >(tee >(cat >&/dev/ttys000))

Output will show in both terminals in real-time even as you type.

Works on linux and macOS. The macOS TTY path is /dev/{number} while on Linux it's /dev/pts/{number}

  • executing exec &> >(tee >(cat >&/dev/ttys000)) does not exists, making it impossible to type.
    – Alex Jones
    Apr 18, 2019 at 19:15
  • @EdwardTorvalds on linux the tty will be something like /dev/pts/0 Apr 18, 2019 at 19:17
  • yeah, that is what I used to test your code
    – Alex Jones
    Apr 20, 2019 at 16:55
  • @EdwardTorvalds what command doesn't exist? Apr 20, 2019 at 21:48
  • your command exec &> >(tee >(cat >&/dev/pts/1)). No control key combination (ctrl+c) work. I have to kill the terminal to exit
    – Alex Jones
    Apr 21, 2019 at 8:11

You can use wall also:

$ wall "Message here"
  • you might wanna describe it in detail. I don't understand anything from this
    – Alex Jones
    Feb 11, 2016 at 15:08
  • 3
    You definitely do not want to use wall (short for "write all"), as it writes to every logged-in tty session, including the one you're sending from. Instead, using write allows a specific tty to be declared. Feb 11, 2016 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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