pts(4)
π pts(4) β pseudoterminal master and slave, bestie edition π
okay so real talk, this is the pts(4) page from the Kernel Interfaces Manual, and it's about ptmx and pts β the pseudoterminal master and slave. it's giving "the plumbing behind every terminal you've ever loved" and honestly? iconic. π
β¨ NAME β¨
ptmx, pts β pseudoterminal master and slave π¦
πΈ DESCRIPTION πΈ
so. the file /dev/ptmx β that's the pseudoterminal multiplexer device β is a character file with major number 5 and minor number 2, usually with mode 0666 and ownership root:root. no cap, that's the whole spec. π
and what is it for? it's used to create a pseudoterminal master and slave pair. that's the job. that's the assignment. π
when a process opens /dev/ptmx, it gets a file descriptor for a pseudoterminal master, and a pseudoterminal slave device gets created in the /dev/pts directory. and listen β every single file descriptor you get from opening /dev/ptmx is an independent pseudoterminal master with its own associated slave. no sharing, no overlap. its path can be found by passing the file descriptor to ptsname(3). π«Ά
β οΈ before opening the pseudoterminal slave, you must pass the master's file descriptor tograntpt(3)andunlockpt(3). this is not optional. the way that you literally cannot skip this step. π
once both the pseudoterminal master and slave are open, the slave provides processes with an interface that is identical to that of a real terminal. like, indistinguishable. main character energy. π
here's the tea on how data flows π:
- data written to the slave is presented on the master file descriptor as input.
- data written to the master is presented to the slave as input.
okay and in practice? pseudoterminals are used for implementing terminal emulators such as xterm(1) β where data read from the pseudoterminal master is interpreted by the application in the same way a real terminal would interpret the data. and also for implementing remote-login programs such as sshd(8) β where data read from the pseudoterminal master is sent across the network to a client program that is connected to a terminal or terminal emulator. networking AND terminals?? versatile queen. π
and there's more!! pseudoterminals can also be used to send input to programs that normally refuse to read input from pipes β such as su(1) and passwd(1). yes bestie, that's your way in. π
π FILES π
/dev/ptmx,/dev/pts/*
π NOTES π
the Linux support for all of the above β known as UNIX 98 pseudoterminal naming β is done using the devpts filesystem, which should be mounted on /dev/pts. iykyk. β¨
π₯ SEE ALSO π₯
and that's the whole page, bestie!! π this one's from Linux man-pages 6.20, dated 2025-12-26 β go forth and multiplex your pseudoterminals responsibly, mwah ππ¦πΈ
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms