| 1 |
.\" Copyright, the authors of the Linux man-pages project |
| 2 |
.\" |
| 3 |
.\" %%%LICENSE_START(FREELY_REDISTRIBUTABLE) |
| 4 |
.\" Redistribute and revise at will. |
| 5 |
.\" %%%LICENSE_END |
| 6 |
.\" |
| 7 |
.TH pts 4 2025-12-26 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
ptmx, pts \- pseudoterminal master and slave |
| 10 |
.SH DESCRIPTION |
| 11 |
The file |
| 12 |
.I /dev/ptmx |
| 13 |
(the pseudoterminal multiplexer device) |
| 14 |
is a character file with major number 5 and |
| 15 |
minor number 2, usually with mode 0666 and ownership root:root. |
| 16 |
It is used to create a pseudoterminal master and slave pair. |
| 17 |
.P |
| 18 |
When a process opens |
| 19 |
.IR /dev/ptmx , |
| 20 |
it gets a file |
| 21 |
descriptor for a pseudoterminal master |
| 22 |
and a pseudoterminal slave device is created in the |
| 23 |
.I /dev/pts |
| 24 |
directory. |
| 25 |
Each file descriptor obtained by opening |
| 26 |
.I /dev/ptmx |
| 27 |
is an independent pseudoterminal master with its own associated slave, |
| 28 |
whose path can |
| 29 |
be found by passing the file descriptor to |
| 30 |
.BR ptsname (3). |
| 31 |
.P |
| 32 |
Before opening the pseudoterminal slave, you must pass the master's file |
| 33 |
descriptor to |
| 34 |
.BR grantpt (3) |
| 35 |
and |
| 36 |
.BR unlockpt (3). |
| 37 |
.P |
| 38 |
Once both the pseudoterminal master and slave are open, the slave provides |
| 39 |
processes with an interface that is identical to that of a real terminal. |
| 40 |
.P |
| 41 |
Data written to the slave is presented on the master file descriptor as input. |
| 42 |
Data written to the master is presented to the slave as input. |
| 43 |
.P |
| 44 |
In practice, pseudoterminals are used for implementing terminal emulators |
| 45 |
such as |
| 46 |
.BR xterm (1), |
| 47 |
in which data read from the pseudoterminal master is interpreted by the |
| 48 |
application in the same way |
| 49 |
a real terminal would interpret the data, and for implementing remote-login |
| 50 |
programs such as |
| 51 |
.BR sshd (8), |
| 52 |
in which data read from the pseudoterminal master is sent across the network |
| 53 |
to a client program that is connected to a terminal or terminal emulator. |
| 54 |
.P |
| 55 |
Pseudoterminals can also be used to send input to programs that normally |
| 56 |
refuse to read input from pipes (such as |
| 57 |
.BR su (1), |
| 58 |
and |
| 59 |
.BR passwd (1)). |
| 60 |
.SH FILES |
| 61 |
.IR /dev/ptmx , |
| 62 |
.I /dev/pts/* |
| 63 |
.SH NOTES |
| 64 |
The Linux support for the above (known as UNIX 98 pseudoterminal naming) |
| 65 |
is done using the |
| 66 |
.I devpts |
| 67 |
filesystem, which should be mounted on |
| 68 |
.IR /dev/pts . |
| 69 |
.SH SEE ALSO |
| 70 |
.BR getpt (3), |
| 71 |
.BR grantpt (3), |
| 72 |
.BR ptsname (3), |
| 73 |
.BR unlockpt (3), |
| 74 |
.BR pty (7) |