Ctrl+C Linux – Fixing Ctrl+C Not Working in Single User Mode on Linux

consolegrub2linuxsignals

I don't know if "single user mode" is the correct term for that but here I go:

On the GRUB menu, I pressed E to edit the run configurations. To the line that starts with linux, I have appended the following:

rw init=/bin/bash

and pressed F10. The computer boots up to a root shell without asking any password.

The problem is, signals are not working. For example, when I run a command, I cannot exit from that command by pressing Ctrl + C.

Is this expected? If yes, what is the reason for this and how can I fix this? Is it related to the terminal emulator in single user mode?

Best Answer

Single user mode has not been the right term for quite some time. In the 1990s, what used to be single user mode split into emergency mode and rescue mode. You are not in fact using either one.

What you are actually doing is a poor idea, because it involves running a program as process #1 that is not designed to do the jobs that process #1 actually needs to do. You would be better off using emergency or rescue modes, the latter of which is invoked by the accepted answer that the answer that you point to, itself points to.

Yes, signals will act oddly. Process #1 has special semantics for signals, for starters, which is one of the several reasons that init=/bin/bash is a poor idea. Furthermore, job control shells cannot do job control when /dev/console is their standard I/O but nothing has set up a proper session with a controlling terminal, as the Bourne Again shell actually told you as soon as it started up.

It is possible with some simple chain-loading tools to set up a proper session with a controlling terminal, and thence enable job control and signal delivery to a foreground process group, but that does not fix all of the other things that will go wrong with /bin/bash as the process #1 program because you have to carefully do them explicitly, by hand.

Just use rescue mode or emergency mode.

Further reading

Related Question