On ubuntu server, how can I avoid the screen being cleared just before the login screen pops?
I'm trying to read an error message on one of the services and I get this annoying clear screen and I cannot scroll up with shift-pageUp.
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
Viewing the last screen of messages that appeared during boot
When Ubuntu Server boots, the messages you see are typically written to tty7 (the seventh virtual console). When booting completes, you are switched to tty1, where you are prompted to log on. Thus, the boot messages are not actually cleared; you are simply switched to a different console from the one that contains them.
To view them again, you can switch to tty7 by pressing Alt+F7. You can switch back to tty1 with Alt+F1 (and to the second with Alt+F2, and so forth). This does not (and should not) apply on most Ubuntu Server systems, but when a GUI is running, Ctrl+Alt+F1 must be used to switch to tty1 (and Ctrl+Alt+F2 for tty2, and so forth).
Preventing the screen from being cleared after a user logs out, so the text from their session is visible in the subsequent session
In your home directory there is a file called .bash_logout which contains something like:
if [ "$SHLVL" = 1 ]; then [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q fi
That is what causes the screen to be cleared on logout. To stop that from happening, comment out all those lines, so it looks like:
#if [ "$SHLVL" = 1 ]; then # [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q #fi
console=tty1 to your
GRUB_CMDLINE_LINUX (I also suggest to add
noplymouth to inhibit
plymouth and its useless splashscreen).
#> sudo vi /etc/default/grub GRUB_CMDLINE_LINUX="console=tty1 noplymouth"
This forces the kernel log to be printed on
tty1 instead of
tty7 and avoid the
tty switch before the login prompt.
Then just go into
/etc/init and edit one or more of
console.conf. I edited them all adding
--noclear option to the
getty command. For example, editing
#> sudo vi /etc/init/tty1.conf
you'll have to replace:
respawn exec /sbin/getty -8 38400 tty1
respawn exec /sbin/getty -8 38400 --noclear tty1
That's all, run
sudo update-grub and now your system should boot in a single
tty without clearing it.