How do I permanently disable Linux's console screen saver, system-wide?
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";
Related videos on Youtube
raldi
Updated on September 17, 2022Comments
-
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?
-
Roy over 11 yearsSeems to be nicely answered over at askubuntu: askubuntu.com/questions/138918/…
-
David C. over 8 yearsI wrote of two different approaches that I needed for various RHEL distributions. One of them may help you with Ubuntu: superuser.com/a/1004931/197972
-
-
raldi about 14 yearsThat doesn't seem to actually work in rc.local.
-
raldi about 14 yearsHow 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 about 14 yearsIt'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 over 12 yearsWhat do I restart when having KBD config change ?
-
Vincent about 12 yearsSeems to be /etc/init.d/kbd reload
-
BaronVonKaneHoffen almost 12 yearsWord 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 almost 12 yearsI 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 over 11 yearsYour 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 over 11 yearsDoes not work on CentOS 6.3. Screen continues to blank out after 10 minutes.
-
Michael Hampton over 11 yearsTo what distributions does this apply?
-
codehead over 11 yearsAs seen on superuser.com/questions/152347/… !
-
pkerts over 11 years@Zoredache you're right, I've added an explanation. Thanks for the feedback.
-
user3132194 over 9 yearsUsing grub2 it could be added in /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="consoleblank=0"
and then updating grub config withgrub[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 almost 9 yearsThis works on Debian 6 and 7. This config file sets
BLANK_TIME=30
by default. -
David C. over 8 yearsI 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 over 5 yearsThis does not exist on ubuntu 18.04 :( - any alternatives?
-
Roman Gaufman over 5 yearsI get this < ~$ sudo setterm -blank 0 setterm: terminal xterm-256color does not support --blank