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.

  • 1
    Error messages are more than likely to be logged in a file in /var/log/. I would start looking at boot.log and syslog. – Rinzwind Aug 21 '11 at 14:42
  • Thanks for your answer Rinzwind. Yes, I know that but for that I need to log into the system and sometimes it is not possible. I just want an easy way to check what happened at boot from the console and the clear screen at the login is not allowing me to see that. – Jorge Molina Aug 21 '11 at 14:50
  • 1
    I still need to remove the clear screen before the login screen. Must be somewhere. Thx tho. – Jorge Molina Aug 21 '11 at 14:58
  • 2
    It's annoying that there still seems to be no convenient way to get the boot messages logged somewhere. Whenever I'm facing such a problem, I take out my camera, take a short clip and play it back in slow motion. :-/ – htorque Aug 21 '11 at 15:36
  • 1
    To see boot messages you can check the /var/log/boot.log, /var/log/syslog, /var/log/dmesg files. – Jorge Molina Aug 21 '11 at 16:04

for systemd set TTYVTDisallocate to no.

to achieve this, run systemctl edit getty@tty1 and enter the code below

  • I am running Ubuntu 16.04 server, and this is the only thing that worked for me. I didn't need any of the other answers. – stefansundin Dec 12 '16 at 6:15
  • 2
    16.4 server, worked for me. I used this more detailed description – Zefiro Mar 12 '17 at 1:50
  • The more detailed description given by @Zefiro also worked for me in Raspbian Jessie, where systemctl edit complained about Unknown operation 'edit'.. Thanks for that link. – Ruslan Jul 9 '17 at 7:54

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

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
  • Thx for the info but that doesn't fix my issue. I'm only looking for a way to remove the clear screen command before the first login screen. – Jorge Molina Aug 21 '11 at 16:02
  • @Jorge Molina Are you not able to view those messages by switching to the 7th virtual console (Alt+F7)? – Eliah Kagan Aug 21 '11 at 16:15
  • Yes, I can. I guess this should do the trick for now. Thank you! – Jorge Molina Aug 21 '11 at 19:01
  • @Jorge Molina I've edited my post to include that information, and expanded upon it for the benefit of people who may be less familiar with virtual consoles / virtual terminals. – Eliah Kagan Aug 21 '11 at 22:53
  • I just installed Ubuntu Server 16.4 LTS and there are only the terminals ALT-F1 to ALT-F6, nothing beyond. – Zefiro Mar 12 '17 at 0:42

After hours of googling, I found the solution in this thread and this question.

First, add 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 tty1.conf, tty2.conf, tty3.conf, tty4.conf, tty5.conf, tty6.conf or console.conf. I edited them all adding --noclear option to the getty command. For example, editing tty1.conf:

#> sudo vi /etc/init/tty1.conf

you'll have to replace:

exec /sbin/getty -8 38400 tty1


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.

  • 1
    I could be wrong but does one need update-grub after editing /etc/default/grub – nhed Mar 15 '16 at 14:09
  • 1
    Yes, you are right sudo update-grub is necessary to regenerate grub.cfg, thanks for the correction. – Avio Mar 17 '16 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.