On a Linux system, what is the difference between /dev/console
, /dev/tty
and /dev/tty0
?
What is their respective use and how do they compare?
consolelinuxtty
On a Linux system, what is the difference between /dev/console
, /dev/tty
and /dev/tty0
?
What is their respective use and how do they compare?
Best Answer
From the Linux Kernel documentation on Kernel.org:
In the good old days
/dev/console
was System Administrator console. And TTYs were users' serial devices attached to a server.Now
/dev/console
and/dev/tty0
represent current display and usually are the same. You can override it for example by addingconsole=ttyS0
togrub.conf
. After that your/dev/tty0
is a monitor and/dev/console
is/dev/ttyS0
.An exercise to show the difference between
/dev/tty
and/dev/tty0
:Switch to the 2nd console by pressing Ctrl+Alt+F2. Login as
root
. Typesleep 5; echo tty0 > /dev/tty0
. Press Enter and switch to the 3rd console by pressing Alt+F3. Now switch back to the 2nd console by pressing Alt+F2. Typesleep 5; echo tty > /dev/tty
, press Enter and switch to the 3rd console.You can see that
tty
is the console where process starts, andtty0
is a always current console.