4

I've been trying to understand the /dev/console device, but there are a few things I'm not clear on:

  1. What is the purpose of this device? From what I can gather it's just a place for the kernel to display messages, is that right?

  2. The virtual terminal that is assigned as the console isn't allowed to have job control. Why? Is that just because the kernel is trying to stop you from running anything else in the place that it needs to print system messages?

  3. For me, /dev/console seems to point to tty0, the current virtual console. I found this based on some simple testing and it seems to be a fairly common configuration. However, to me this indicates that tty0 should have job control disabled, which would mean that all consoles should have job control disabled, which would be bad. It's giving me a headache just thinking about it. Also, if tty0 is the console, then shouldn't I be getting kernel messages on the current terminal instead of just on tty1?

1

3 Answers 3

2

This is largely a historical holdover from days when the operations console was an actual teletype that printed (made indelible marks) on a piece of paper (a thin flexible material made from wood fiber, often white). Over time, these have largely been directed to the syslog and dmesg facilities since very few systems now have an actual console but the information is still needed.

I don't know where you got the idea that /dev/console was tty0; on my Linux 3 box, /dev/console, tty, and ttyprintk all have a device major number of 5 while tty0 and all the rest of the pseudo-ttys are major device 4. This means that they use different drivers (or radically different modes of the same driver).

1
  • Original poster meant that access to /dev/console produces effects equivalent (and possibly calls the same kernel routines) to access to /dev/tty0, on a usual Linux box. Downvote for not addressing the question essentially. Commented Sep 14, 2015 at 15:21
1

This book gives a good introduction to Linux ttys, and fgreping for register_console in Linux kernel’s drivers/char/*.c shows what’s going on with Linux console. There are many implementations of the system console available in the Linux kernel. A specific Linux installation can decide which particular device should serve as the console. It can be specified by passing kernel parameters on boot, or possibly other techniques exist. The implementation is the default one, and arguably de facto standard, but other exist as well, such as .

/dev/console has its own dedicated major:minor. Why? Because the kernel itself is a major user of the kernel device when reports emergency messages there. There is struct tty_driver *console_driver kernel object pointing to routines needed. Then why don’t provide an interface to it for userland programs as well? Have no idea whether is /dev/console, for the default setup, really equivalent to /dev/tty0, or there are some differences.

Now about job control at tty0. How could it be possible if tty0 doesn’t really emulate a terminal but only points to a tty that is currently active? Linux kernel prevents processes from attaching to tty0, a “device” that intermittently collides with tty1, … tty7 and so on. Since tty0 can’t control processes, there is no job control possible (by the way, for which legitimate purpose can tty0 feed a shell at all?). But this has nothing to do with possibility to control jobs that run on specific virtual consoles. Other numbered ttys are, in fact, legitimate terminals for any purpose of a console application.

-2

The /dev/console is an abstraction of the local terminal session - console associated with the monitor plugged into the machine.

Its purpose, mainly on servers, is to provide remote access even if the system is running in single-user mode. Such console is (in most cases) bound to the eth0 device when the eth0 networking is turned off.

1
  • System console bound to eth0, seriously? Given there is no such special file as eth0, how is it implemented? Elaborate, please. Commented Sep 14, 2015 at 15:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .