About nixCraft

Topics

Linux disable screen blanking i.e. preventing screen going blank

Posted by Vivek Gite [Last updated: May 13, 2006]

It is easy to disable screen saver under X window. But when it comes to text based login or terminal you will not find easy way to disable text based power saving mode (i.e. when your screen goes blank after a few minutes).

So how do I disable the blank screen mode, which activated after a few minutes? Answer is use setterm command.

setterm writes to standard output a character string that will invoke the specified terminal capabilities. Where possible terminfo database (terminfo is a data base describing terminals, used by screen-oriented programs and libraries such as ncurses) is consulted to find the string to use.

By default, the Linux kernel will use screen-save option to disable it you need to type command (it turns off monitor VESA powersaving features):

$ setterm -powersave off -blank 0

If it dumps back you with an error that read as follows:

cannot (un)set powersave mode

You need to shutdown X window system and rerun the above command. Better, add following two commands to your ~/.xinitrc file:

setterm -blank 0 -powersave off -powerdown 0
xset s off

Other useful options

This command also supports other useful options:
Resets the terminal to its power on state:

$ setterm -reset

Alternatively, initialize terminal:

$ setterm -initialize

Turns the terminal's cursor on or off:

$ setterm -cursor [on|off]

Turns automatic line-wrapping on or off (virtual consoles only)

$ setterm -linewrap [on|off]

Sets the foreground text color (virtual consoles only):

$ setterm -foreground blue

Sets the background text color (virtual consoles only):

$ setterm -background red

Enables or disables the sending of kernel printk() messages to the console (virtual consoles only). Useful if you get lots message from iptables firewall:

$ setterm -msg [on|off]

I regularly use these (above) options.

See also:

E-mail this to a Friend    Printable Version

Is your site working? Monitor Your Web Site 24/7. Get SMS alerts on server downtime. Free 30-day trial including 20 SMS!

You may also be interested in other helpful articles:

Discussion on This Article:

  1. Graeme Says:

    I wouldn’t use “setterm -msg off”, as you don’t get useful panic messages. Rather use “dmesg -n1″, so that you still get panic messages but not all the trivial junk to the console. Otherwise thank you for a useful page

  2. Helge Says:

    Your guide was a great help, however it wasn’t enough for a clean approach on my Ubuntu 7.10 system.

    I don’t have an .xinitrc, so instead I put this in ~/.bashrc:
    xset s off > /dev/null 2>&1
    and this in /etc/rc.local
    sh -c 'setterm -blank 0 -powersave off -powerdown 0 /dev/console 2>&1'
    This also does not produce errors even though I’m running an X session.

  3. Helge Says:

    Somehow copy-paste screwed up before.
    Here’s the code for rc.local:
    sh -c 'setterm -blank 0 -powersave off -powerdown 0 /dev/console 2>&1'

  4. Helge Says:

    I’m very sorry to “spam” like this >_<
    Figured < was interpreted as an HTML-tag.
    Hopefully it should work now:
    sh -c 'setterm -blank 0 -powersave off -powerdown 0 < /dev/console > /dev/console 2>&1'

  5. Matt Simmons Says:

    Great tips. Screen blanking used to irritate me on the console, too. Especially for my servers which I KVM into. There’s no screen to burn out, so why should the term go blank?

    Anyway, I wanted to add that sometimes I’ll do something dumb, like cat’ing a binary file, and it completely screws the terminal window. The way to recover from that is just the ‘reset’ command. A lot of people probably don’t know that.

    Before I learned about it, sometimes I’d be up to 3 or 4 terminals lost to garbage on the screen. Logging out never helped, and I used to have to restart the machine to recover them. ‘reset’ fixed that.

  6. Neverb Says:

    also you can just execute
    echo -e ‘33[9;0]33[14;0]‘
    if your terminal supports CSI-sequences (if you use linux - you may shure that it does)

  7. Neverb Says:

    omg, ‘\33[9;0]\33[14;0]‘ i mean

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.