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 Ibmi Media, we shall look into a summary of the differences between tty (/dev/tty ) vs pts (/dev/pts) in Linux.
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.
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:
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.
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.
This article covers the differences between pts and tty. In fact, it also shows you how to overview the Linux system.