setterm
from @whitequark's answer is a reasonable userspace tool, but it's not the whole story.
The default console blanking behavior is baked into the kernel at compile time. It is configurable at boot time with the paramater consoleblank=, or in userspace with setterm
. From the kernel documentation (kernel-parameters.txt):
consoleblank= [KNL] The console blank (screen saver) timeout in
seconds. Defaults to 10*60 = 10mins. A value of 0
disables the blank timer.
Here are the options, their defaults on my Ubuntu system, and their spheres of influence:
-
setterm -blank [0-60]
; always reports 0 when queried; effective when run on a real VT; affects all real TTYs; not effective when run in screen sessions on a VT. -
setterm -powerdown [0-60]
; always reports "3]" (??); doesn't seem to have any effect. Ubuntu kernels don't enable APM_DISPLAY_BLANK, and this could be related. -
consoleblank=N
; defaults to 600 (10 minutes); affects all real VTs; affects screen sessions in a VT; no way to set while running.
So my options for changing the default is one of the following:
- Add
setterm -blank X
(X in minutes, 0 to disable) to a shell init file like .bashrc. - Add
setterm -blank X
to /etc/rc.local. - Add
consoleblank=Y
(Y in seconds, 0 to disable) to the kernel commandline by adding it to the parameter lists in /etc/default/grub, either GRUB_CMDLINE_LINUX orGRUB_CMDLINE_LINUX_DEFAULT. (Don't forget toupdate-grub
.)