Sample Header Ad - 728x90

what relations are between my current controlling terminal and `/dev/tty`?

9 votes
2 answers
2950 views
On Lubuntu 18.04, I run a shell in lxterminal. Its controlling terminal is the current pseudoterminal slave: $ tty /dev/pts/2 I would like to know what relations are between my current controlling terminal /dev/pts/2 and /dev/tty. 1. /dev/tty acts like my current controlling terminal /dev/pts/2: $ echo hello > /dev/tty hello $ cat < /dev/tty world world ^C 2. But they seem to be unrelated files, instead of one being a symlink or hardlink to the other: $ ls -lai /dev/tty /dev/pts/2 5 crw--w---- 1 t tty 136, 2 May 31 16:38 /dev/pts/2 13 crw-rw-rw- 1 root tty 5, 0 May 31 16:36 /dev/tty For different sessions with different controlling terminals, if /dev/tty is guaranteed to be their controlling terminals. How can it be different controlling terminals, without being a symlink or hardlink? So what are their relations and differences? Any help is much appreciated! This post is originated from an earlier one https://unix.stackexchange.com/questions/446166/do-the-output-of-command-tty-and-the-file-dev-tty-both-refer-to-the-control
Asked by Tim (106420 rep)
May 31, 2018, 08:40 PM
Last activity: Feb 14, 2020, 04:06 PM