Linux Commands

What Is Dev/Pts in Linux

Dev/pts is a pseudoterminal stimulated by programs like Telnet and SSH. Since the advent of Microsoft Windows, Linux is only used as an additional operating system instead of a sole or primary OS. That’s why there is a need for pseudoterminals to use the UNIX and Linux programs. Dev/pts files store information related to the connected devices through Linux in special directories.

When devices like the keyboard and mouse are directly connected to the computer through serial ports, the connection is called TTY. Read this guide if you are curious about the /dev/pts. In this guide, we will explain about /dev/pts in Linux.

What Is /dev/pts in Linux?

The /dev/pts signifies the master files related to the pseudoterminal slave or a master, and the system saves it as /dev/ptmx. You can open the descriptors of these master files using the grantpt and unlockpt commands.

Applications such as xterm and Telnet help fool the Linux operating system that it is running on a dummy terminal when it is used along with another OS like Windows. The program data is presented to the files like it is run on an actual terminal by using the data to the slave file as input for the master file.

This process is stored in directories listed as the dev/pts file system in Linux that aids the functioning of such pseudoterminals. If you stop with /dev, it signifies an ordinary file directory in the regular flow of files. But if you use the /dev/pts, it is associated with the special directory available only in the kernel created by Linux. Every unique terminal window is related to a Linux pts entry in the /dev/pts system.

Use the “w” command to view the pseudoterminal to which the application is connected. Here, you can get the details about the concerned applications through which the pseudoterminal is connected:

w

The devpts file directory has different mounts of files in such a manner that each mount has different indices according to the assigned pts and is unique from one another.

You can also use the mount command to verify whether the dev/pts files are mounted in Linux.

sudo mount devpts /dev/pts

There are many kinds of pseudoterminals applications that you can use for Linux, such as GUI terminals inclusive of xterm and console, remote shell applications, and multiplexer applications.

A single pseudoterminal can receive multiple outputs from different programs at a time. Multiple programs routing to the same terminal for reading would confuse the multiple inputs.

It is essential to understand that the files stored virtually in the /dev/pts directories are abstract and not real files. The data related to the programs on execution are stored temporarily while the pseudoterminals are in use. If you open the /dev/pts as files, it would usually be less useful.

Sometimes, it is possible that the command system is not suitable for mounting the devpts files. You can see if the file systems are listed in the output after running the following command:

cat /proc/filesystems

If your Linux kernel does not support this system, you can download the latest version that supports the dev/pts files.

Conclusion

The /dev/pts is a special virtual temporary file directory unique to the Linux system while running the programs through pseudoterminals. While these files do not necessarily store permanent records of related data, they contribute by associating the reading or writing a program in each terminal and storing the crucial information for successfully running the programs through pseudoterminals.

About the author

Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.