Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

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
up vote 59 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
Dammit. When Ī̲ wrote unix.stackexchange.com/a/229598/80483 , Ī̲ was unaware of this answer! – Incnis Mrsi Sep 14 '15 at 15:11
  • /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 kind of an alias to the console (physical, virtual or pseudo device, if any) associated to the process that open 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
What do you mean by querying it from this statement "/dev/tty is the console used by the process querying it"? – Ron Vince Sep 19 '15 at 2:33
@RonVince I mean /dev/tty can be a different device, if any, depending on the process that open it. Answer updated. – jlliagre Sep 19 '15 at 8:28
Thanks. May I know are processes actually write/read to/from /dev/tty instead of directly to/from device file associated to them? – Ron Vince Sep 19 '15 at 14:55
@RonVince I'm afraid I'm not sure what you are asking. Could you rephrase it? – jlliagre Sep 19 '15 at 20:36
@RonVince Opening /dev/tty (not /dev/tty[1,..,n]) is the Unix (and Linux) standard for a process to write something to the user's terminal. Directly writing to whatever other device is non portable, more complex and less reliable. A process doesn't need to know what is the actual device the process terminal is connected to, the kernel knows it already. – jlliagre Sep 20 '15 at 15:31

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.