Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
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

3 Answers 3

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 
share|improve this answer

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
share|improve this answer

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'
share|improve this answer
2  
You probably then want to alias this lot to something handy. –  Danny Staple Sep 24 '11 at 21:33
    
vbetool is available via sudo apt-get install vbetool –  David Clarke Mar 8 at 6:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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