In my initramfs, I have;

[root@xilinx Peta_Microzed_15_05]# ls  initramfs/dev/
[root@xilinx Peta_Microzed_15_05]# nano  initramfs/dev/console
[root@xilinx Peta_Microzed_15_05]# 

The above nano opens an empty file.

So what kind of this file console is if it has nothing inside it ?

1 Answer 1


Most files in /dev are device files. These are special directory entries, which do not correspond do any disk storage, but instead invoke functions in the kernel, typically to interact with hardware.

Unix systems support several types of files (I'm omitting some “exotic” types), which are indicated by the first character on the line in the output of ls -l:

  • - Regular files. For disk-backed filesystems, these files are written to disk. When you read a file of this type, you get back the data that was written to it.
  • d Directories. These are files whose sole purpose is to contain other files.
  • l Symbolic links. These are files whose sole purpose is to redirect to another file.
  • p Named pipes (also known as FIFOs): when a process writes to a named pipe, another process reads the output in real time, and the writer blocks until the reader does its reading.
  • s Named sockets — like named pipes, but offering a session-based bidirectional communication like network sockets.
  • b, c Block and character devices.

A block device is a device that acts much like a fixed-size regular file: when you read back from a given location, you get back the data that was last written at that location. Block devices are typically disks or disk partitions or other hardware that acts like a disk.

A character device is a device that doesn't act in this way. These are highly varied. Some devices are output-only or input-only; even when a character device supports both input and output, there is not necessarily any relation between what is written and what is read. For example, data written to a device that corresponds to a serial port is sent to the peripheral connected to that serial port; data read from that device is what is received from that peripheral.

/dev/console designates the system console, i.e. the keyboard and screen connected to the computer. If a computer has no keyboard and screen, /dev/console exists but writing to it may fail or be ignored. If a computer has multiple keyboards and screens, some system configuration determines which one(s) /dev/console is connected to. Some Unix flavors offer virtual consoles; for example, on Linux, you can switch between consoles by pressing Ctrl+Alt+F1, Ctrl+Alt+F2, etc.; each console has its own set of programs connected to it and its own video buffer, and switching switches which console receives keyboard input and is displayed on the screen.

You can read from /dev/console (assuming you have permission). Nano is being somewhat unhelpful: it refuses to read from any device file (which is highly sensible, since it doesn't make any sense to “edit” a character device, and block devices normally contain filesystems which should not be edited with a text editor), but it doesn't display an error message.

Given the name of the directory, this is an initramfs tree: a tree of files which is meant to become the initial file tree of a Linux system. If you assemble the initramfs (typically done as part of a kernel build) and boot from that initramfs, this console file will end up as /dev/console on the system you booted.

You must log in to answer this question.

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