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.)









發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章