Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
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
1  
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
show 1 more comment

2 Answers 2

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
share|improve this answer
    
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
add comment

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:

respawn
exec /sbin/getty -8 38400 tty1

with:

respawn
exec /sbin/getty -8 38400 --noclear tty1

That's all, now your system should boot in a single tty without clearing it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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