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'
  • 2
    You probably then want to alias this lot to something handy. – Danny Staple Sep 24 '11 at 21:33
  • 1
    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 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 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 
  • How do I know which screen is which – Karl Morrison Jul 30 '17 at 15:26
  • 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
  • 1
    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
  • 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
  • If you got crtc error, then type "chvt 7" before xrandr command, so that it reads "chvt 7 && xrandr -d :0 --output eDP1 --auto" – haytham-med haytham Nov 11 '17 at 6:36

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.

  • 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

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 execute the command the screen will turn off automatically every minute (if idle).

Enjoy!

  • Executing the above command I get: "setterm: terminal xterm-256color does not support --blank". What can be wrong? – zx485 Sep 19 at 21:23
  • Are you trying from a remote session? – Boy Graffity Sep 20 at 1:41

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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