linux 字符界面禁止黑屏

setterm from @whitequark's answer is a reasonable userspace tool, but it's not the whole story.

The default console blanking behavior is baked into the kernel at compile time. It is configurable at boot time with the paramater consoleblank=, or in userspace with setterm. From the kernel documentation (kernel-parameters.txt):

consoleblank=  [KNL] The console blank (screen saver) timeout in
               seconds. Defaults to 10*60 = 10mins. A value of 0
               disables the blank timer.

Here are the options, their defaults on my Ubuntu system, and their spheres of influence:

  • setterm -blank [0-60]; always reports 0 when queried; effective when run on a real VT; affects all real TTYs; not effective when run in screen sessions on a VT.
  • setterm -powerdown [0-60]; always reports "3]" (??); doesn't seem to have any effect. Ubuntu kernels don't enable APM_DISPLAY_BLANK, and this could be related.
  • consoleblank=N; defaults to 600 (10 minutes); affects all real VTs; affects screen sessions in a VT; no way to set while running.

So my options for changing the default is one of the following:

  1. Add setterm -blank X (X in minutes, 0 to disable) to a shell init file like .bashrc.
  2. Add setterm -blank X to /etc/rc.local.
  3. Add consoleblank=Y (Y in seconds, 0 to disable) to the kernel commandline by adding it to the parameter lists in /etc/default/grub, either GRUB_CMDLINE_LINUX orGRUB_CMDLINE_LINUX_DEFAULT. (Don't forget to update-grub.)









  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值