Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

讓 Linux 開機自動開啟 NumLock

編輯:Linux 教學

問題背景

許多使用者希望 Linux 開機後數字鍵盤的 NumLock 自動開啟。網路上常見的作法是在 /etc/rc.d/rc.local 加入迴圈呼叫 setleds +num,但實測往往無效,NumLock 指示燈不亮。

正確解法

關鍵在於必須加上 -D 參數,才能修改預設旗標。正確的腳本如下:

for t in 1 2 3 4 5 6 7 8
do
    setleds -D +num < /dev/tty$t > /dev/null
done

原理解析

  • setleds 若無 -D,僅改變目前虛擬終端的 LED 狀態,不影響預設值。
  • -D 會更新「預設旗標」,使所有虛擬終端(tty1~tty8)啟動時即生效。
  • 同理,將 +num 改為 +caps 或 +scroll 可控制 CapsLock、ScrollLock。

建議

遇到設定問題時,優先查閱 man setleds,理解參數含義可避免走彎路。

Copyright © Windows教程網 All Rights Reserved