I can see the difference between /dev/tty and /dev/tty0 by testing the provided method from this question. But I really wonder about the practical usage of those devices (like situations they will be used).
Linux – How /dev/tty and /dev/tty0 Are Used
deviceslinuxterminaltty
Best Answer
/dev/tty
is the controlling tty of the current process, for any process that actually opens this special file. It isn’t necessarily a virtual console device (/dev/tty
n), and can be a pty, a serial port, etc. If the controlling tty isn’t a virtual console, then the process has not to interact with console devices even if its pseudotty is actually implemented on the system console. E. g. for a shell in a terminal emulator under locally-running X server, said programs form such chain of interactions as:Unix shell
⇕
/dev/pts/2
(≡/dev/tty
for its processes)kernel pty driver
⇕
/dev/ptmx
terminal emulator
⇕ X Window protocol
X server
⇕
/dev/tty7
(≡/dev/tty
for the server)system console
zxc↿⇂[_̈░░]
user
Use of
/dev/tty
by userland programs includes:/dev/tty0
is the currently active (i. e. visible on the monitor) virtual console of the operating system. This special file unlikely is used significantly by system software, but/dev/console
is virtually an “alias” fortty0
and/dev/console
has much use by syslog daemons and, sometimes, by the kernel itself.Experiment to show the difference: run a
root
shell ontty3
(Ctrl+Alt+F3) or in a terminal emulator. Nowthen quickly Ctrl+Alt+F2, wait for two seconds, and Ctrl+Alt+whatever back. Where do you see the output?
And now the same test for
/dev/tty0
.