Linux – Prevent the console from clearing the screen

consolekernellinux

When booting into Linux, there are sometimes one or two lines that get quickly cleared. I think that some of them don't even appear in dmesg. If nothing else, I want to suppress the clear before the "login:" prompt. Is there a kernel command or sysctl that I can set to prevent this so I can read them on the console screen after booting?

Best Answer

Most of the information you want will be in /var/log/dmesg and /var/log/messages after the system boots, you should check those files first.

Generally linux machines run mingetty for the virtual terminals. If you have a traditional sysv init system, those are controlled by /etc/inittab. You can add the --noclear option to mingetty to prevent clearing the screen. To do this, edit /etc/inittab and change this line:

1:2345:respawn:/sbin/mingetty tty1

to

1:2345:respawn:/sbin/mingetty --noclear tty1

then reboot the machine.

Some newer linux distros use init replacements like Upstart (for example, Ubuntu). These generally don't use /etc/inittab and instead use some other config files. Here's a discussion of how calling mingetty works on Ubuntu.