https://unix.stackexchange.com/a/492304/674 says

On Linux, using devpts, there is no master device file. The process on the master end uses a file descriptor, which it gets by opening ptmx, but there’s no corresponding device node.

Did the author refer to /dev/ptmx or /dev/pts/ptmx?

Why are /dev/ptmx and /dev/pts/ptmx not device files? What types of files are they?

What is the difference between /dev/ptmx and /dev/pts/ptmx?


On Lubuntu 18.04

$ file /dev/ptmx 
/dev/ptmx: character special (5/2)
$ file /dev/pts/ptmx 
/dev/pts/ptmx: character special (5/2)

$ sudo su

# stat -L /dev/fd/3 3<> /dev/pts/ptmx
  File: /dev/fd/3
  Size: 0           Blocks: 0          IO Block: 1024   character special file
Device: 15h/21d Inode: 2           Links: 1     Device type: 5,2
Access: (0000/c---------)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2018-11-21 13:39:10.544000218 -0500
Modify: 2018-11-21 13:39:10.544000218 -0500
Change: 2018-11-21 13:39:10.544000218 -0500
 Birth: -

# stat -L /dev/fd/3 3<> /dev/ptmx
  File: /dev/fd/3
  Size: 0           Blocks: 0          IO Block: 4096   character special file
Device: 6h/6d   Inode: 87          Links: 1     Device type: 5,2
Access: (0666/crw-rw-rw-)  Uid: (    0/    root)   Gid: (    5/     tty)
Access: 2019-01-06 07:19:54.372098540 -0500
Modify: 2019-01-06 07:19:54.372098540 -0500
Change: 2018-11-21 13:39:30.372098540 -0500
 Birth: -
  • 1
    They're not? Then why file command say they are? I double checked, they really are. It's just how you rephrase your language, nothing big deal, almost every thing is used through a file descriptor on linux, but "file" is not well-defined . See man7.org/linux/man-pages/man7/pty.7.html and man7.org/linux/man-pages/man4/pts.4.html. – 炸鱼薯条德里克 Jan 6 '19 at 5:52
  • I can't check this right now, but does stat -L /dev/fd/3 3<> /dev/ptmx show a major/minor of 5 and 2, or something else? – Mark Plotnick Jan 6 '19 at 9:51
  • @MarkPlotnick yes. updated. – Tim Jan 6 '19 at 12:22
  • @MarkPlotnick /dev/ptmx will multiplex a new pty pair on opening it, no matter what path is used for that; your command will actually create 2 pseudo-terminal pairs. – mosvy Jan 6 '19 at 14:11

The context was “A pseudoterminal has a pair of master and slave.” When I wrote “there is no master device file”, I meant that there is no device node in the file system corresponding to the master end of a pseudoterminal connection, unlike the slave end. I wasn’t referring to either /dev/ptmx or /dev/pts/ptmx.

/dev/ptmx and /dev/pts/ptmx are device nodes, as indicated by their type in the output of ls or stat. They have the same major and minor, which means they provide access to the same device.

See JdeBP’s answer to Where does `/dev/pts/ptmx` come from? for the history of both device nodes (and the reason why there are two on Linux nowadays).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.