tty (/dev/tty ) vs pts (/dev/pts) in Linux

tty is simply the ports connected to the computer like a mouse, keyboard. pts are pseudo terminals that are SSH or telnet connections. You can understand tty and pts as connection channels to which Linux systems communicate with the client. Both are responsible for keeping sessions alive and sending packets.

Here at LinuxAPT, we shall look into a summary of the differences between tty (/dev/tty ) vs pts (/dev/pts) in Linux.


What is tty ?

Tty stands for teletype, however, it's more commonly referred to as a terminal. It's essentially a device that lets you interact with a system by delivering data (you input) to the system and viewing the system's output. A standard terminal device is referred to as a tty (for example, the console on your server). ttys come in a variety of shapes and sizes. For example, you can use the Ctrl+Alt+Fn key combination to access graphical consoles, or terminal emulators like Gnome terminal to run inside an X session.


How does the tty command work?

Simply type 'tty' and the name of the terminal connected to standard output will appear in the output (or, in other words, the name of the current terminal):

Syntax is:

$ tty [option] ……

tty command options includes:

  • – – version: Prints the version information and exits
  • – – help: display the help message and exits
  • -s, ––silent, ––quiet: Nothing is printed; only the exit status is returned.

To put it another way, type TTY to find out what TTY number you’re connected to. You may also use the who command to see who else is connected to the Linux machine remotely if there are several users connected.

To get the list of open terminals, you can use the following command:

$ ps aux | grep tty

By default, the total number of allowed tty consoles is 6. You can switch tty1 to tty6 using CTRL+ALT+F[n] key combinations.


What is pts?

pts stands for pseudo terminal slave. Pts is the slave part of pty. A pty (pseudo-terminal device) could be a terminal device that another application simulates (example: telnet or ssh are such programs. A pseudo-terminal slave (pts) session is used when connecting to a Linux computer via another application, such as SSH or PuTTY. The tty command will show which pts session is currently active. When using an SSH connection, the Ctrl + Alt + F# combos will not work. Instead, numerous SSH connections would be used to create multiple virtual consoles.

You can simply view the pts channel with w command. In the following output, user kushal is connected to tty1 which might be a console connection and pts/0 which is through ssh.


Important terms about TTY includes:

  • terminal = tty = text input/output environment.
  • Teletypewriter originally and now also means any terminal on Linux/Unix systems. It also means any serial port on Unix/Linux systems.
  • A tty is a regular terminal device (the console on your server, for example).
  • tty consoles are managed by systemd in Red Hat Enterprise Linux 7 OS.
  • tty consoles are created on-the-fly upon access.
  • The allowed number of consoles can be configured in /etc/systemd/logind.conf file.
  • Set NAutoVTs= value in this file to desired number to have systemd capable of generating those many tty consoles.


Important terms about PTS includes:

  • Stands for pseudo terminal slave.
  • A pts is the slave part of a pty.
  • A pty (pseudo terminal device) is a terminal device which is emulated by an other program (example: xterm, screen, or ssh are such programs).
  • /dev/pts contains entries corresponding to devices. /dev/pts is a special directory that is created dynamically by the Linux kernel. The contents of the directory vary with time and reflect the state of the running system.
  • The entries in /dev/pts correspond to pseudo-terminals (or pseudo-TTYs, or PTYs).
  • In laymen terms the primary difference between TTY and PTS is the type of connection to the computer. TTY ports are direct connections to the computer such as a keyboard/mouse or a serial connection to the device. PTS connections are SSH connections or telnet connections. All of these connections can connect to a shell which will allow you to issue commands to the computer.


[Need help in fixing Linux system issues ? We can help you. ]

This article covers the differences between pts and tty. In fact, it also shows you how to overview the Linux system.

Related Posts