I am runnning Ubuntu Server on my laptop. There is really no reason for the screen to be on. I have been trying to use this command to turn the screen off:

sleep 1 && xset dpms force off

The problem is I get the following error

unable to open display "".

Any idea what is going on / what is wrong? Any other suggestions for how to do this?

  • Do you have an X server installed? And it is running? – enzotib Sep 24 '11 at 20:55
  • @enzotib I do believe it is installed. As for it running, I am not sure. How can I check? – AngryBird Sep 24 '11 at 20:56
  • 1
    Try running this first: export DISPLAY=:0.0 – RobinJ Sep 24 '11 at 21:00
  • Non null output from dpkg -l | grep xserver-xorg to be installed. Non null output from pgrep -fl X to be running. By the way, if running you should be in a graphical session. – enzotib Sep 24 '11 at 21:03
  • 1
    @WarriorIng64: it is a laptop – enzotib Sep 25 '11 at 8:39

To turn off monitor in console, the command is the following:

sudo vbetool dpms off

To regain control of the console on pressing Enter key, I suggest

sudo sh -c 'vbetool dpms off; read ans; vbetool dpms on'
| improve this answer | |
  • 3
    You probably then want to alias this lot to something handy. – Danny Staple Sep 24 '11 at 21:33
  • 3
    vbetool is available via sudo apt-get install vbetool – David Clarke Mar 8 '14 at 6:21
  • 1
    In my case this command really turned the display off and not the xset one – golimar Feb 10 '17 at 16:58
  • Strangely enough the command turns off 2 of 3 displays, the third remaining white for a while before having the machine reboot on its own if the command was executed over ssh. – danba Mar 4 '18 at 20:05
  • @enzotib, I clicked accidentally to downvote, sorry. Please edit a bit the answer to I can remove the downvote. – andras.tim Mar 5 '18 at 8:57

Try these commands...

To Turn Off:

xset -display :0.0 dpms force off 

To Turn On:

xset -display :0.0 dpms force on 

If your display turns off and then immediately back on then try the following which adds a delay of 1 second before turning the screen off. This give a chance for all events to be processed by the X server before turning the display off.

sleep 1 && xset -display :0.0 dpms force off 
| improve this answer | |
  • How do I know which screen is which – Karl Morrison Jul 30 '17 at 15:26
  • 1
    The following worked for me (also partially inspired by @enzotib's answer): xset -display $DISPLAY dpms force off; read temp; xset -display $DISPLAY dpms force on – stiemannkj1 Aug 4 '17 at 2:52
  • Be careful with this. I'm unable to turn my monitor back on with a test machine after issuing force off – Zmart Oct 31 '17 at 17:02
  • 3
    Update: Pulling out and replugging all cables (including power) on the monitor has remedied the situation. – Zmart Oct 31 '17 at 17:08

The xset command mentioned in other answers will turn off all the monitors if you have multiple monitor setup. However if you want turn off only one or some of the monitor you should use xrandr.

First run xrandr -q command, which will list all the monitors and its current display settings. At the start of each monitor details you will find monitor name set by the system. You have to keep track of that.

I have two monitors (one is connected to DVI port and other to VGA port) and when I run the command I see this:

Screen 0: minimum 320 x 200, current 1360 x 768, maximum 2726 x 2726
DFP1 connected 1360x768+0+0 (normal left inverted right x axis y axis) 304mm x 228mm
   1360x768       59.7*+
   ... (more details are shown here, but I have hidden it)

CRT1 connected 1360x768+0+0 (normal left inverted right x axis y axis) 410mm x 230mm
   1360x768       59.8*+   60.0  
   ... (more details are shown here, but I have hidden it)

In this output, DVI port connected monitor is labelled as DFP1 and other one as CRT1. So if I want turn off the secondary monitor(i.e., CRT1) I have run this command:

xrandr --output CRT1 --off

if you want switch on that monitor again then you have run this command:

xrandr --output CRT1 --auto
| improve this answer | |
  • I have 3 Monitors, 1 VGA, 1 DVI and 1 HDMI. When i ran: xrandr --output VGA1 --auto, it turned the VGA on, but it cloned the DVI monitor. – ThiagoPonte Feb 23 '15 at 0:43
  • Hmm strange. Try --on instead of --auto – Harshith J.V. Feb 23 '15 at 2:58
  • @HarshithJ.V. this is a good answer! Its better than the xset because xset turns on if you just press the touchpad etc. Btw hope you remember me from your previous company :-) – Nishant Nov 13 '16 at 18:05
  • @Nishant Thanks for compliments. Strangely I don't remember you. Please ping me on any other social media as we can't chat over as its against the rules. – Harshith J.V. Apr 14 '17 at 5:00
  • 1
    thank you for your answer, I would only add that (as in the case of @ThiagoPonte) xrandr --output DP-5 --auto --right-of CRT1 allows to turn back on the monitor without cloning (replace --right-of with whatever your setup is) – Louis Gagnon Jan 8 at 8:41

I've just installed Ubuntu Server 18.04.1 (no GUI, X, nor anything graphical), and after breaking my back last night trying to turn off the screen I finally found the magic command:

setterm --blank 1

After executing the command the screen will turn off automatically every minute (if idle).

And even better, if you want the command to be executed automatically at boot, you can add it to the GRUB commandline, to do so we have to edit the next file:

sudo nano /etc/default/grub

Once there, just add consoleblank=60 to GRUB_CMDLINE_DEFAULT, it should look like this:

GRUB_CMDLINE_LINUX_DEFAULT="quiet consoleblank=60"

Then close the file and save it, after that just run sudo update-grub and voila, every time you boot the screen will turn off automatically every 60 sec. (again, if idle).

And this way (adding the consoleblank to the GRUB) works even from remote terminals (ssh).

Enjoy! (again)

| improve this answer | |
  • 1
    Executing the above command I get: "setterm: terminal xterm-256color does not support --blank". What can be wrong? – zx485 Sep 19 '18 at 21:23
  • 1
    Are you trying from a remote session? – Boy Graffity Sep 20 '18 at 1:41
  • @zx485 Check out the updated answer, now you can make the screen turn off from a remote session. I'm sure this will solve your problem – Boy Graffity Jun 8 '19 at 20:34
  • Just what I was looking for! This is usually included by default in most distros but not server-centric ones like proxmox. Works like a charm. – pinkeen Apr 28 at 16:57
  • 2
    Caution! The value passed to setterm --blank is minutes not seconds. I was scratching my head for a while until decided to read TFM. – pinkeen Apr 28 at 17:25

If you have multiple monitors use this:

Turning off your second monitor:
(Assuming CRT-0 is your left monitor and CRT-1 is your right monitor)
xrandr --output CRT-1 --off
Turning on your second monitor:
xrandr --output CRT-1 --right-of CRT-0 --auto
This way xrandr knows not to duplicate the first screen.

| improve this answer | |
  • I was testing this, turning off a screen this way is more like disabling it, eg, the screen is still powered on. Its just not used. The --off'd screen cannot be turned back on with the screen's power button (because its still on / was never off). It also messed with my desktop display settings, (from extended desktop to mirrored displays). If this was done to turn both displays off, I'm not sure it would be easy to turn them back on without logging in to TTY and clearing the monitors.xml file wherever it is. The more you know. – ThorSummoner Dec 12 '16 at 18:02

Blank screen after 1 min and turn it off after 2 min. Any keypress will turn it back on. Make it auto-start after reboot.

The magic command what will do all the work:

setterm --blank 1 --powerdown 2

If you get error: setterm: terminal xterm-256color does not support --blank

  • You are probably trying this command by SSH. You must run it from local of your machine, or do next stage of this guide.

Make it auto-start

Insert command in executable file. Store it for example in hidden folder of your home directory /home/USER/.boot-scripts/screen-off.sh

setterm --blank 1 --powerdown 2

And make script file executable by systemctl. Create file /etc/systemd/system/screen-off.service

Description=Blank screen after 1 min and turn it off after 2 min. Any keypress will turn it back on.



Make it executable:

    sudo chmod +x /home/USER/.boot-scripts/screen-off.sh
    sudo chmod +x /etc/systemd/system/screen-off.service

And finally get it working and enabled on boot:

sudo systemctl start screen-off.service
sudo systemctl enable screen-off.service

To disable it:

sudo systemctl disable screen-off.service
| improve this answer | |
  • Why does it need to start after ssh.service? – Andy Forceno Dec 15 '19 at 14:44
  • no effect on macbook pro – Drew Feb 5 at 20:44
  • service works perfectly on Ubuntu Linux using systemd; thanks for the fantastic tutorial. This is great for a laptop server. Also @Drew this is "Ask Ubuntu" not "Ask Different" the instructions are for Linux not macOS. – cody.codes Jun 5 at 6:21
  • I guess @Drew is running Ubuntu on his Macbook Pro... setterm --blank 1 --powerdown 2 doesn't seem to work on those machines. – TCB13 Jun 17 at 21:31

@stiemannkj1's answer(inspired by @enzotib's answer) buried in the comments to @harshith-j-v's answer (works on my laptop connected to a monitor):

xset -display $DISPLAY dpms force off; read temp; xset -display $DISPLAY dpms force on

Maybe a mod or site developer can make a way to pull good comments out to a separate answer so that attributions and reputation scoring can be settled correctly

| improve this answer | |
  • I added sleep 1; in the beginning, as otherwise the monitor would immediately turn back on. – Michael Litvin Aug 11 at 18:53

I was having the same problem. What I discovered is that on my laptop (an old acer aspire) the default screentoggle button is supported. This could be something like fn+F6.

This solution probably didn't work back in the day. I hope it'll help anyone that encounters this problem.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.