Lets learn "About tty files in linux"

 

In this tutorial, we'll learn about the tty files we have in Linux, About what are these files, where are these files used, etc. 

Basically, in Linux, everything is a file. Even hardware connected to a Linux system is also a special file. tty mean TeleType also known as terminal. Similar to other things, the terminal is also a file in the Linux system. And these terminal files are the tty files. So the definition of tty files ( or Terminal ) can be written as:

Its a device, that allows you to interact with the system bypassing the data ( you provided ) to the system and printing the output produced by the system.


tty commands in linux

tty [OPTIONS]...

If you run tty command on the Linux terminal, it will simply return the tty file for the current terminal window from where the command is running.

Example

Let's take an example to understand this correctly. When someone ssh to a host, it lands you to a terminal. And when there is a terminal, there must be a tty file for that as well. Let's verify this.

After ssh to host from one place.

$ tty
/dev/pts/0

$ ls -la /dev/pts
ls -la /dev/pts
total 0
drwxr-xr-x  2 root root      0 Oct  4 08:43 .
drwxr-xr-x 18 root root   3100 Oct  4 08:43 ..
crw--w----  1 root tty  136, 0 Oct  4 19:20 0

Now after ssh to the same host from other system. The expectation is a new tty file should be created.

$ tty
/dev/pts/1

$ ls -la /dev/pts
total 0
drwxr-xr-x  2 root root      0 Oct  4 08:43 .
drwxr-xr-x 18 root root   3100 Oct  4 08:43 ..
crw--w----  1 root tty  136, 0 Oct  4 19:22 0
crw--w----  1 root tty  136, 1 Oct  4 19:22 1

Similarly, if we ssh to the same host from another place we'll see yet another tty file.

HOPE YOU LIKE THIS TUTORIAL. IF YOU HAVE ANY DOUBT FEEL FREE TO COMMENT BELOW. STAY TUNED FOR MORE TUTORIALS :)

Comments

Popular posts from this blog

Lets learn "About kube proxy in iptables mode"

Lets learn "System design for paste bin (or any text sharing website)"

Lets learn "What is CDN?"