Server Fault is a question and answer site for system and network administrators. 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

This is in one of the rc scripts in Red Hat and I want to understand the purpose of > /dev/tty[n]

 for i in `LC_ALL=C grep '^[0-9].*respawn:/sbin/mingetty' /etc/inittab | sed 's/^.* tty\([0-9][0-9]*\).*/\1/g'`; do    
 > /dev/tty$i

To simplify the question for those having trouble understanding the script, what does the following code do exactly? (it seems to send a null value to /dev/tty but why?)

> /dev/tty1
> /dev/tty2
share|improve this question
I understand all of the rest of it, but I want to know only about the 3rd line. – user160910 Apr 23 '13 at 15:06
Which rc script? – larsks Apr 23 '13 at 15:28
Are you sure you got the spacing correct in the sed bit? This looks wrong, there appears to be spaces where there shouldn't be. 's/^.* tty\ ([0- 9][0-9]*\).*/\1/g. – Zoredache Apr 23 '13 at 16:33
The formatting got screwy when I copied it here, I fixed the spacing. This is the rc.sysinit script. Anyone know the answer to my question? – user160910 Apr 23 '13 at 18:30
up vote 0 down vote accepted

It outputs text to Linux virtual console N (Ctrl_Alt_n). In snippet you've quoted this would redirect output to every Linux Virtual Console supposed to have mingetty run on.


(it seems to send a null value to /dev/tty but why?)

This might have a purpose of virtual consoles initialization — man 4 console:

Before kernel version 1.1.54 the number of virtual consoles was compiled into the kernel (in tty.h: #define NR_CONSOLES 8) and could be changed by editing and recompiling. Since version 1.1.54 virtual consoles are created on the fly, as soon as they are needed.

— so, yep, it looks like on-demand creation.

share|improve this answer

Your Answer


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