Linux command
setleds 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Turn on NumLock LED
setleds +num
Turn off CapsLock LED
setleds -caps
Turn on ScrollLock LED
setleds +scroll
Set NumLock as default
setleds -D +num
Report current LED status
setleds
Change LEDs only
setleds -L +num
Set LEDs for a specific TTY
setleds -D +num < /dev/tty1
说明
setleds controls the keyboard LED indicators (NumLock, CapsLock, ScrollLock) on Linux virtual consoles. Without arguments, it reports the current LED and flag settings. The command manipulates both the virtual terminal flags (which affect keyboard behavior) and the physical LED states. Use -F to change only VT behavior, -L to change only LEDs, or -D to set persistent defaults. This is commonly used in /etc/rc scripts to set the initial NumLock state for console logins.
参数
- +num / -num
- Set or clear NumLock
- +caps / -caps
- Set or clear CapsLock
- +scroll / -scroll
- Set or clear ScrollLock
- -F
- Only change VT flags (default); LEDs may reflect the change
- -D
- Change flags and defaults; changes persist after console reset
- -L
- Only change LEDs without affecting VT flags
- -v
- Verbose mode; report changes
FAQ
What is the setleds command used for?
setleds controls the keyboard LED indicators (NumLock, CapsLock, ScrollLock) on Linux virtual consoles. Without arguments, it reports the current LED and flag settings. The command manipulates both the virtual terminal flags (which affect keyboard behavior) and the physical LED states. Use -F to change only VT behavior, -L to change only LEDs, or -D to set persistent defaults. This is commonly used in /etc/rc scripts to set the initial NumLock state for console logins.
How do I run a basic setleds example?
Run `setleds +num` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does +num / -num do in setleds?
Set or clear NumLock