TTY/PTS

用語意味
ttyはteletypewriter)native terminal device
pty (pseudo terminal device)terminal device which is emulated by an other program (example: xterm, screen, or ssh are such programs).
pts (pseudo terminal slave)A pts is the slave part of a pty

自分の端末

$ tty
/dev/pts/9 

ログイン中のユーザー一覧

$ w
 19:34:16 up 20:31, 10 users,  load average: 2.02, 1.64, 1.59
USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
mike     :1        Thu23   ?xdm?   3:48m  0.01s /usr/lib/gdm-x-session --run-script /usr/bin/gnome-session
mike     pts/1     Thu23   44:27   0.00s  0.00s tmux
mike     pts/2     Thu23   44:27  12.17s  4.01s /usr/bin/python /usr/bin/pipenv shell
mike     pts/3     Thu23    0.00s  0.00s  0.00s tmux
mike     pts/4     Thu23   19:55m  2:47   2:46  mdbook serve -p=5000
mike     pts/5     Thu23    3:59m  2.12s  0.06s psql -h localhost -p 5432 -U root -W root
mike     pts/6     Thu23   18:35m  1.81s  0.92s /usr/bin/python /usr/bin/pipenv shell
mike     pts/8     Thu23   20:12m  0.27s  0.27s -zsh
mike     pts/9     Thu23    0.00s  8.45s  0.02s w
mike     pts/10    Thu23    2:45m  0.56s  0.56s -zsh

別ターミナルにコマンドを送る

fdの

$ ps
    PID TTY          TIME CMD
  17935 pts/10   00:00:00 zsh
 113650 pts/10   00:00:00 ps
$ ll /proc/17935/fd
dr-x------ mike mike  0 B Fri Sep 11 19:42:51 2020  .
dr-xr-xr-x mike mike  0 B Fri Sep 11 17:14:09 2020  ..
lrwx------ mike mike 64 B Fri Sep 11 19:42:53 2020  0 ⇒ /dev/pts/10
lrwx------ mike mike 64 B Fri Sep 11 19:42:53 2020  1 ⇒ /dev/pts/10
lrwx------ mike mike 64 B Fri Sep 11 19:42:53 2020  10 ⇒ /dev/pts/10
lr-x------ mike mike 64 B Fri Sep 11 19:42:53 2020  11 ⇒ /home/mike/.antigen/init.zsh.zwc
lrwx------ mike mike 64 B Fri Sep 11 19:42:53 2020  2 ⇒ /dev/pts/10

別のターミナルにメッセージ送信

echo "test" > /dev/pts/10