- How to Turn Off Monitor Using Command-line in Ubuntu 20.04
- vbetool Utility
- Using xset
- Using xrandr to Turn off Single Monitor
- How to turn off the display via the command line?
- 6 Answers 6
- How to power down display on terminal?
- 2 Answers 2
- Manually turn off monitor
- 6 Answers 6
- Keyboard Shortcut to Turn Display Off in Linux
- Turn Display Off From the Linux Command Line
- Set Keyboard Shortcut to Turn Off Display
- Conclusion
How to Turn Off Monitor Using Command-line in Ubuntu 20.04
If you do not need to stare at your computer terminal and want to turn off the monitor to save energy or whatever reason then there are a couple of commands at your disposal.
vbetool Utility
You can use the vbetool utility to turn off the display as follows. First, install the utility using apt.
$ sudo apt-get install vbetool
Run the following command to turn off the display.
To regain control of the console by pressing Enter key, use the following command:
$ sudo sh -c 'vbetool dpms off; read ans; vbetool dpms on'
Using xset
You can use xset to turn of the display using:
$ xset -display :0.0 dpms force off
or turn on the display using:
$ xset -display :0.0 dpms force on
You can set a delay before the monitor goes off to allow all events to be processed by the X server before turning the display off using the following:
$ sleep 1 && xset -display :0.0 dpms force off
Using xrandr to Turn off Single Monitor
You can use xrandr to turn off a specific monitor seeing the other methods here act on all monitors. Run the following command to list your monitors:
Assuming your monitor is identified as CRT1 then you would run the following to turn it off.
Or the following to turn it on:
Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.
How to turn off the display via the command line?
Is there a way to turn off the display (enter power saving mode) using a command? For example, when the computer is inactive for a specific interval, the screen turns off to conserve energy. Is there a way to manually turn off the screen, yet keep the computer running normally? This is a notebook, so there’s no ‘power-off’ button on the monitor itself.
6 Answers 6
I think you are looking for
However, you need to make sure that your acpi is enabled. You can check this with
setterm -powersave powerdown
Sometimes the Enter keypress as you execute the command can be enough to immediately wake the computer back up again. I usually go with sleep 0.2s && xset dpms force off just to be safe. Also, this makes for a nice replacement for locking your screen: gnome-screensaver-command —lock && sleep 2s && xset dpms force off
I just did the same thing in kubuntu using info from this answer: xdg-screensaver activate && sleep 2s && xset dpms force off
I’m running Ubuntu Server without X on a 2007 MacBook Pro. The display is sleeping by itself but won’t reactivate when a key is pressed on the keyboard. At this point my fix is to use vbetool . Install using apt-get :
sudo apt-get install vbetool
Then use to turn display on via SSH from a different machine:
vbetool is what I search for exactly! It turn the monitor off completely via BIOS VESA drivers/tools. Just like turning off by using hard key of the monitor!
doesn’^t work (macbook air old) mmap /dev/zero: Operation not permitted Failed to initialise LRMI (Linux Real-Mode Interface).
I have made a unity launcher to turn off the LCD
sudo apt-get install --no-install-recommends gnome-panel gnome-desktop-item-edit ~/Desktop/ --create-new
It will open a small windows. Enter the following:
Command: gnome-screensaver-command —lock && sleep 2s && xset dpms force off
You can also choose an icon by clicking the icon on the left .
(sleep 10; xset dpms force suspend) & xdg-screensaver lock
This starts the screen saver in locked mode and then puts your display in standby. Ubuntu Mate 15.10
xset dpms force off worked only for 5 seconds.
I searched the internet and found the following script, and after a small change it worked perfectly.
#!/usr/bin/python import time import subprocess from Xlib import X from Xlib.display import Display display = Display(':0') root = display.screen().root root.grab_pointer(True, X.ButtonPressMask | X.ButtonReleaseMask | X.PointerMotionMask, X.GrabModeAsync, X.GrabModeAsync, 0, 0, X.CurrentTime) root.grab_keyboard(True, X.GrabModeAsync, X.GrabModeAsync, X.CurrentTime) subprocess.call('xset dpms force off'.split()) #original #p = subprocess.Popen('gnome-screensaver-command -a'.split()) #changed p = subprocess.Popen('xset dpms force off'.split()) time.sleep(1) while True: print display.next_event() p.terminate() break
How to power down display on terminal?
Which gives a blank screen; but active screen (screen still receives output from computer, just blank output, it won’t enter a «no signal» state) How would I turn off the display completely like you can do from X with this?
xset dpms force off #wake xset dpms force on
2 Answers 2
Blank screen after 1 min and turn it off after 2 min. Any keypress will turn it back on:
setterm --blank 1 --powerdown 2
sudo sh -c 'vbetool dpms off; read ans; vbetool dpms on'
This seems like it would work. but for me I always just get an illegal instruction error. I’m gonna see what happens if I install the cpu microcodes though. although I’d kinda rather avoid those. Edit: Nope, microcodes did not fix this, so I cannot use this method, guessing it has something to do with arch-linux.
Duh, otherwise it would be command not found. Illegal Instruction typically means that the action requires an instruction set (like AVX or SSE) that your CPU doesn’t support, since this is interfacing with the graphics, might maybe be GPU (idk, I have an i7-2600 sandy bridge and a gtx 550-Ti on proprietary drivers, I would think this should be supported unless the nvidia drivers don’t support it)
It makes sense in a way :), can you please also take a look at this? wiki.archlinux.org/index.php/Display_Power_Management_Signaling
Not really any new information there, I looked at it before I wrote my question. I woulda thought powerdown is the feature I need, but it only offers setting a timer for powerdown, not to just simply power down now.
Manually turn off monitor
Can I turn off my laptop monitor manually and instantly with just a click or a simple terminal command? I just want to turn off my monitor not locking my machine. There is no dedicated turn off monitor button on my machine.
6 Answers 6
- To turn off the monitor $ xset dpms force off
- To turn on the monitor $ xset dpms force on
Pressing a key or moving the mouse will also switch the monitor on if it has been turned off. You can assign the command to a key if you like using shortcuts.
It works, thanks.. I’m just wondering, can I make it to slowly fade off just like when my computer about to sleep?
Is there a way to use this commant with locking my screen? When I lock my screen my monitors don’t turn off, just go black. I want to save power by turning them off while also locking my session. Any ideas?
xset dpms force standby seems to be more reliable and doesn’t need the sleep 1 ; xset dpms force off trick.
Is there any way to apply this only one of two screens? I have multiple displays setup and would like to turn off only one of them e.g. when I watch a movie…
To add on to the other answer, I found that when I entered xset dpms force off and pressed the Enter key, my screen would turn off and turn on again. By running the command below, I was able to get the screen to turn off without turning on.
sleep 3; xset dpms force off
This method should work everywhere since DPMS or Display Power Management System has appeared in 1993 and by now is integral part of X. If it doesn’t work, that probably means there’s hardware issue, or some really serious bug.
Just to add more options. You can run
xrandr --output --brightness 0
To determine your display name, simply run xrandr . It will provide you with information on connected displays, so you can actually turn on and off any of them
Beware though, after running this command, you won’t be able to turn your screen on by moving your mouse or using a keyboard. You will have to either use second monitor or blindly type
xrandr --output --brightness 1
So, X RandR provides you with better control over your screens, but it does what it does. It can also be used for other things, like changing resolution, orientation, rate, etc. It is also very easy to run it inside scripts. If you want, you can write a script to make your screen nicely fade to black. Brightness parameter can take fractions
Note that —brightness option doesn’t actually affect hardware, it only colorizes screen in such way that it becomes dark. Quote from the manual on —brightness option: However, this is a software only modification, if your hardware has support to actually change the brightness, you will probably prefer to use xbacklight .
In Ubuntu 18.04, dpms not working properly with GNOME Wayland
$ xset -q DPMS (Energy Star): Display is not capable of DPMS
You can try the command below,
to turn off monitor:
busctl --user set-property org.gnome.Mutter.DisplayConfig /org/gnome/Mutter/DisplayConfig org.gnome.Mutter.DisplayConfig PowerSaveMode i 1
busctl --user set-property org.gnome.Mutter.DisplayConfig /org/gnome/Mutter/DisplayConfig org.gnome.Mutter.DisplayConfig PowerSaveMode i 0
I found the xset dpms force off command works well. However, when assigning a hot key to this command, I ran into trouble: my screen would turn off and back on again.
I found the reason for this was the hot key combo I was using for no particular reason. I discovered the hot key combo «Mod2+Mod4+Super+Hyper+Left shift» assigned to the xset dpms force off command turns the screen off and the screen will not turn on again until a key is pressed or the mouse is used. Exactly what I wanted! That hot key combo is simply the Super (Windows key) used in conjunction with the left shift key. I’m running Ubuntu 16.04 and this is working on my systems.
If you want to do this remotely over an SSH session, you’ll need to specify the DISPLAY number, e.g.,
DISPLAY=:1 xset dpms force off
If you want to do it for the login screen,
sudo -u gdm env XAUTHORITY=/run/user/$(id -u gdm)/gdm/Xauthority DISPLAY=:0 xset dpms force off
Without the XAUTHORITY bit you’ll get the mysterious error
No protocol specified xset: unable to open display ":0"
In general, if some program is using the display, you can figure out how it’s talking to the display server by looking at its environment variables:
$ ps aux | grep gd[m] … gdm 1643 0.1 0.2 3784328 164396 tty1 Sl+ 08:59 0:01 /usr/bin/gnome-shell … $ sudo cat /proc/1643/environ | tr '\0' '\n' … DISPLAY=:0 … XAUTHORITY=/run/user/126/gdm/Xauthority …
I happened to recognize these specific environment variables as critical, but in a pinch you could use binary search to narrow down the relevant ones. Try running xset with all the environment variables copied over, and if that works, comment out half of them to see if it still works without, and so on.
Keyboard Shortcut to Turn Display Off in Linux
There are times when I want to turn off the displays on my workstation, but not actually lock it. In this Linux quicktip we will show you how to turn your displays off using the command line. We will also show you how to use that command as a keyboard shortcut, or HotKey.
Turn Display Off From the Linux Command Line
To turn your display(s) off from the command line we will use the xset utility.
The xset utility allows you to change user preference options for the display. The dpms part is specific Energy Star parameters or options. We use force off to tell the system to instantly switch dpms to the off state.
Set Keyboard Shortcut to Turn Off Display
In Gnome you can easily create a shortcut to trigger this command.
First, go into setting by selecting the top right tray.
From the settings menu, select «Keyboard Shortcuts».
Now scroll all the way to the bottom of the list. There you will find a plus sign at the bottom of the list that allows you to add your own custom shortcuts.
When you click the plus sign you will be shown the «Add Custom Shortcut» window which requires some input. First, let’s name it something relevant. For this example I named the shortcut «Display Off».
In the command section we will call the xset utiltiy, just as we did on the command line above.
Last, we need to set the shortcut. Just click it and then enter the key, or keys you want to use. For this example I chose Super+D, which is purposely close to Super+L, which I use all the time.
That’s it, click the Add button and you are all set.
Conclusion
Now you can easily turn off your monitors from the Linux command line, or the Gnome Keyboard Shortcuts. We hope you found this quick tip helpful