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 to grantpt(3) and unlockpt(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