Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

On a Linux system, what is the difference between /dev/console , /dev/tty and /dev/tty0 ?

What is their respective use? How do they compare?

share|improve this question

migrated from serverfault.com Jan 8 '13 at 13:58

This question came from our site for system and network administrators.

You may also be interested in this –  Kevin Jan 8 '13 at 16:20

2 Answers 2

up vote 45 down vote accepted

From the documentation:

/dev/tty        Current TTY device
/dev/console    System console
/dev/tty0       Current virtual console

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 adding console=ttyS0 to grub.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. Type sleep 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. Type sleep 5; echo tty > /dev/tty, press Enter and switch to the 3rd console.

You can see that tty is the console where process starts, and tty0 is a always current console.

share|improve this answer
nice exercise! Ubuntu locks root, so one way to reproduce this on Ubuntu is: $ sudo sh -c "sleep5; echo tty0 > /dev/tty0" –  SFun28 Jan 31 '13 at 20:43
@SFun28, I always used sudo -i, and voila - a root shell. –  André Laszlo Mar 23 '14 at 22:30
nice! Thanks André! –  SFun28 Mar 24 '14 at 13:55
one idiom for writing to files that require root privs is echo stuff | sudo tee /dev/tty0 >/dev/null; –  Peter Cordes Aug 5 '14 at 12:21
  • /dev/console is a virtual set of devices which can be set as a parameter at boot time. It might be redirected to a serial device or a virtual console and by default points to /dev/tty0. When multiple console= options are passed to the kernel, the console output will go to more than one device.

  • /dev/tty0 is the current virtual console

  • /dev/tty[1-x] is one of the virtual consoles you switch to with control-alt-F1 and so on.

  • /dev/tty is the console used by the process querying it. Unlike the other devices, you do not need root privileges to write to it. Note also that processes like the ones launched by cron and similar batch processes have no usable /dev/tty, as they aren't associated with any. These processes have a ? in the TTY column of ps -ef output.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.