59

How to disable blank screensaver on Ubuntu Server?

There's no desktop or X, only console (command-line interface).

ish
  • 138,666
  • 36
  • 303
  • 312
Alex
  • 781
  • 1
  • 8
  • 8

4 Answers4

59

The easiest way is to add the parameter consoleblank=0 to your kernel command-line at boot-time.

  • Open /etc/default/grub in your favorite editor; you will need to use sudo (for vi, nano, etc.) or gksudo (for gedit, etc.).

  • Then add consoleblank=0 to the GRUB_CMDLINE_LINUX_DEFAULT=, parameter.

  • e.g. yours may say:

    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash consoleblank=0"

Then run sudo update-grub, and reboot.

ish
  • 138,666
  • 36
  • 303
  • 312
  • Is there a way to do that from Virtualbox? As in passing an option to the kernel command line? – CMCDragonkai Jun 05 '14 at 04:56
  • @CMCDragonkai This answer works for virtualized Ubuntu as well since it boots using _grub_ by default too. – Melebius Jan 21 '15 at 09:42
  • As in, is there a way to pass it externally from Virtual Box, not from within Ubuntu? – CMCDragonkai Jan 22 '15 at 00:28
  • @CMCDragonkai No, there is no Virtual Box option that will pass on this setting. You have to edit the file as specified above. – Rick Chatham Feb 11 '15 at 22:09
  • 1
    Look: I don't want to update the `grub` files, just to disable the (Blank) ScreenSaver. I'm resorting, to `setterm -blank 0`, maybe in a file `~/.bashrc`. (See also on [superuser.com an answer to Change Linux console screen blanking behavior](https://superuser.com/a/154388/123800)) – metadings Sep 26 '16 at 13:21
  • thank you so much this worked great on headless server ubuntu 19.10 – Kreezxil Nov 10 '19 at 02:04
23

Type setterm -blank 0 on any shell to disable blanking out of tty consoles.

0 disables blanking, any value greater than 0 is the time in minutes. Default is 10.

To permanently enable this you can add this line to your ~/.bashrc config.

A more detailled explaination can be found in this answer at superuser.

q9f
  • 1,221
  • 3
  • 18
  • 29
2

Same situation, the other suggestions seemed a roundabout solution. Came across the GNU tool setvesablank on/off using apropos. It seems the best fit, trying it out to see if it fits the need.

  • In Gnome Terminal on the console it said `Couldn't find a file descriptor referring to the console` - `echo $TERM` returned `xterm-256color - But in "Brightness and Lock" I found a setting for when it blanks the screen and set it to "Never" - but this isn't really on point with the OP since I am in the GUI. – SDsolar Jan 10 '18 at 19:41
1

This will "overwrite" whatever is in your current config for "GRUB_CMDLINE_LINUX_DEFAULT=", mine was default, so I just use the following One Liner.

sudo sed -i 's/\(^GRUB_CMDLINE_LINUX_DEFAULT=\).*/\GRUB_CMDLINE_LINUX_DEFAULT="consoleblank=0"/' /etc/default/grub && sudo update-grub2
FreeSoftwareServers
  • 1,109
  • 1
  • 13
  • 31
  • I had to escape the '"' character: sed --in-place 's/\(^GRUB_CMDLINE_LINUX_DEFAULT=\).*/\GRUB_CMDLINE_LINUX_DEFAULT=\"quiet consoleblank=0\"/' /etc/default/grub – W1M0R Dec 13 '17 at 07:20