Linux: Difference Between /dev/tty, /dev/tty0, and /dev/console

Linux / UNIX supports device files that are stored in the /dev directory. These aren’t actual files, rather, they are special files or character devices that are representative of hardware devices attached to the system.

Some of the most commonly misunderstood device files are /dev/console, /dev/tty, and /dev/tty0. In this guide, we will explore the nuances that distinguish these three device files.

What is /dev/tty in Linux

tty” is short for TeleTYpewriter. It has its origin in the early terminals that were used to connect to computers as teleprinters or teletypewriters.

The /dev/tty file is a special file that represents the terminal for the current process, which displays the terminal associated with the current SSH session.

To check which tty you are currently using, run the following command:

$ tty
OR
$ who am i

The output shows that the current tty is /dev/pts/0. This stands for Pseudo Terminal Slave and is a terminal device emulated by SSH connections or other programs such as xterm or screen.

Check Current TTY in Linux
Check Current TTY in Linux

What is /dev/tty[0-N] in Linux

/dev/tty[0-N] is simply a virtual console that you can switch to from the main terminal if you are running a GUI system where N represents the TTY number. By default, /dev/tty0 is the default virtual console.

For example, if you are running a graphical instance of Ubuntu 22.04, launch your terminal and type CTRL + ALT + F1, which will open a black terminal screen as shown below.

As you can see, from the output, we are using tty1 where 1 corresponds to the Function Key pressed.

Linux Virtual Console
Linux Virtual Console

tty1 through tty63 are virtual terminals, alternatively known as VTs or virtual consoles. And as mentioned, they simulate multiple consoles on top of the physical console device driver.

What is /dev/console in Linux

/dev/console is referred to as the system console, where the boot and kernel messages are displayed on this console during booting. Like other Linux device files, it resides in the /dev directory.

You can confirm by running the following ls command as follows.

$ ls -lah /dev/console
Linux System Console
Linux System Console

/dev/console exists primarily to expose the kernel’s console to user space. It shows messages during system startup (and shutdown as well) and also facilitates the switchover to single-user mode using the init 1 command.

Conclusion

It’s our hope that you can now pick the differences that exist across the three device files that we have just covered. Your feedback on this guide is welcome.

If you read this far, tweet to the author to show them you care. Tweet a thanks
Winnie Ondara
My name is Winnie, a Linux enthusiast and passionate tech writer in Linux and DevOPs topics. I enjoy keeping abreast with the latest technologies in the Linux ecosystem and trying out new tools provided by the FOSS community.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

1 thought on “Linux: Difference Between /dev/tty, /dev/tty0, and /dev/console”

  1. Thanks for explaining about the difference between /dev/tty, /dev/tty0, and /dev/console in Linux, which is very helpful for beginners and freshers.

    Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.