Linux 命令行关闭开启显示器及xset: unable to open display ""解决方法

在远程连接Linux等时,基本用不到显示器,所以希望能远程将显示屏关闭
xset -display :0.0 dpms force off这个命令让显示屏进入休眠状态
xset -display :0.0 dpms force on开启显示屏

sleep 1 && xset dpms force off这个命令关闭屏幕
出现了报错:xset: unable to open display “”
解决方法:输入如下命令

export DISPLAY=:0
xset q

之后再输入sleep 1 && xset dpms force off不再报错

Reference:
https://askubuntu.com/questions/476036/xset-unable-to-open-display

猜你喜欢

转载自blog.csdn.net/Mao_Jonah/article/details/83832312