How to start a linux shell as from /etc/inittab

siebert picture siebert · Jun 30, 2010 · Viewed 7.1k times · Source

We used to have two entries in our /etc/inittab:

::sysinit:/etc/init.d/rcS
ttyS0::respawn:-/bin/sh

rcS is a shell script which normally starts our application, but in a special case we called "return" to terminate it which apparently lets the /bin/sh take over the tty as we got a shell prompt where we could do some maintenance.

Now the inittab looks like this:

::once:/etc/init.d/rcS

We now start the shell by executing "/bin/bash -i" in the rcS script, as we don't want to always run a second shell (due to memory constraints) which is normally never used.

But the created bash doesn't feature job control, which is very limiting.

So my question is, can I create a shell (and maybe terminate the rcS script) the same way the init processed did in our previous solution so that I get again a shell with job control?

Answer

Seth Robertson picture Seth Robertson · May 19, 2011

This depends on exactly what OS you are running. Here is an example which works on RHEL/CentOS.

6:2345:respawn:/sbin/mingetty --autologin root tty6

Here is what someone else did for a similar trick.

openvt -f -c 12 -w -- sh -c "unicode_start; echo -e '$NORPT'; exec $LOGINSH" >/dev/tty1