How do I permanently disable Linux's console screen saver, system-wide?

39,551

Solution 1

In Ubuntu 12.10 and earlier the console-tools package allows console options to be controlled.

To turn off screen blanking and powerdown, set BLANK_TIME and POWERDOWN_TIME to 0 in /etc/console-tools/config. If you'd prefer not to modify the config file, the same effect can be achieved by creating a new file in /etc/console-tools/config.d containing the following:

BLANK_TIME=0
POWERDOWN_TIME=0

The name of the file in config.d must consist entirely of upper and lower case letters, digits, underscores, and hyphens.

Solution 2

Or you use /etc/kbd/config to set up (depends on your system, what is installed)

BLANK_TIME=0
BLANK_DPMS=off

Solution 3

The parameter is controlled via the kernel command line, using setterm merely alters the runtime settings. To disable it system wide you can alter your kernel boot command line by appending it with "consoleblank=0" in your boot configuration (grub/lilo).

If something during boot setterm's it then it will override the value.

Solution 4

If you add the setterm command to /etc/rc.local, it should take effect for all virtual consoles, whether or not a user is logged into them. E.g.:

setterm -blank 0

Solution 5

If you are running a newer Ubuntu that uses upstart, you can use:

for file in /etc/init/tty*.conf; do tty="/dev/`basename $file .conf`"; echo "post-start exec setterm -blank 0 -powersave off >$tty <$tty" | sudo tee -a "$file"; done

A little explanation of what's going on here:

Newer Ubuntu versions use upstart for system startup. With upstart, the Linux consoles are setup with config files stored within /etc/init. The command above starts by iterating over each of those config files:

for file in /etc/init/tty*.conf;

The tty's upstart config file name in $file is used to build the name of the tty device:

tty="/dev/`basename $file .conf`";

An upstart "post-start" command is built that runs "setterm" to disable screen blanking and power saving after the tty has been started:

echo "post-start exec setterm -blank 0 -powersave off >$tty <$tty"

And finally that command is appended to the upstart config file:

| sudo tee -a "$file";
Share:
39,551

Related videos on Youtube

raldi
Author by

raldi

Updated on September 17, 2022

Comments

  • raldi
    raldi almost 2 years

    I've got an Ubuntu server that boots up in text mode. It rarely has a screen or keyboard attached to it, but when I do attach a screen, I usually have to attach a keyboard too, because the darn console mode screen saver will be on and I'll need to hit a key to see what's going on.

    I'm aware that the setterm command can disable this, but it's a per-session thing. How can I make it so the machine never ever blanks the screen in text mode, even when it's first booted up and sitting at the login prompt?

  • raldi
    raldi about 14 years
    That doesn't seem to actually work in rc.local.
  • raldi
    raldi about 14 years
    How you know that? I've been scouring the Internet all morning looking for the documentation for /etc/console-tools and haven't been able to find any.
  • James Sneeringer
    James Sneeringer about 14 years
    It's worked for me in the past on RedHat-type systems. It could be that Debian/Ubuntu load rc.local at a slightly different time than RH. Sorry about that.
  • Frodik
    Frodik over 12 years
    What do I restart when having KBD config change ?
  • Vincent
    Vincent about 12 years
    Seems to be /etc/init.d/kbd reload
  • BaronVonKaneHoffen
    BaronVonKaneHoffen almost 12 years
    Word of warning with this: I installed console-tools on ubuntu server 12.04, did the above config and it completely tanked it... Not sure what I did wrong, but if it happens to anyone else (and you're crap at servers like me!), boot to recovery -> root prompt -> mount -o remount,rw / -> apt-get remove console-tools -> reboot
  • Mayur Bhayani
    Mayur Bhayani almost 12 years
    I tried this in a fresh install of Ubuntu Server 10.04.4 and 12.04.1, and it didn't work in either one.
  • Zoredache
    Zoredache over 11 years
    Your answer would be a lot better if you actually described what is going on here. Just giving huge command like that with no explanation isn't very useful.
  • Michael Hampton
    Michael Hampton over 11 years
    Does not work on CentOS 6.3. Screen continues to blank out after 10 minutes.
  • Michael Hampton
    Michael Hampton over 11 years
    To what distributions does this apply?
  • codehead
    codehead over 11 years
  • pkerts
    pkerts over 11 years
    @Zoredache you're right, I've added an explanation. Thanks for the feedback.
  • user3132194
    user3132194 over 9 years
    Using grub2 it could be added in /etc/default/grub GRUB_CMDLINE_LINUX_DEFAULT="consoleblank=0" and then updating grub config with grub[2]-mkconfig -o /boot/grub/grub.cfg. Or it could be embedded in built-in kernel command line while configuring and compiling kernel manually.
  • basic6
    basic6 almost 9 years
    This works on Debian 6 and 7. This config file sets BLANK_TIME=30 by default.
  • David C.
    David C. over 8 years
    I found that this worked for RHEL 5 and 6 (/bin/setterm -blank 0 -powerdown 0 -powersave off), but not for 7. Success or failure probably depends on your distribution and the console environment at the time rc.local is executed.
  • Roman Gaufman
    Roman Gaufman over 5 years
    This does not exist on ubuntu 18.04 :( - any alternatives?
  • Roman Gaufman
    Roman Gaufman over 5 years
    I get this < ~$ sudo setterm -blank 0 setterm: terminal xterm-256color does not support --blank