LinuxCommandLibrary

setleds

Control keyboard LEDs

SYNOPSIS

setleds [options]

PARAMETERS

-D, --default
    Sets the keyboard LEDs to their power-on default state (Num Lock ON, Caps Lock OFF, Scroll Lock OFF).

-F, --force
    Forces the operation even if the console is not in the expected state (e.g., not a VGA console).

-L, --leds
    Displays the current state of the keyboard LEDs (Caps Lock, Num Lock, Scroll Lock).

-R, --reset
    Resets the LEDs to reflect the current keyboard mode (e.g., Num Lock LED reflects the numeric keypad state).

-C on|off, --caps-lock on|off
    Turns the Caps Lock LED on or off.

-N on|off, --num-lock on|off
    Turns the Num Lock LED on or off.

-S on|off, --scroll-lock on|off
    Turns the Scroll Lock LED on or off.

-h, --help
    Displays a help message and exits.

-V, --version
    Displays version information and exits.

DESCRIPTION

setleds is a utility for manipulating the state of the keyboard's light-emitting diodes (LEDs), specifically those indicating the status of the Caps Lock, Num Lock, and Scroll Lock keys. It provides fine-grained control over these indicators primarily in a Linux console environment.

The command can be used to explicitly turn LEDs on or off, synchronize their state with the current console mode, or revert them to their initial BIOS-determined state. This tool is particularly useful in situations where automated scripts need to manage keyboard states, or for debugging keyboard behavior in text-mode consoles. While less commonly used in modern graphical user interfaces (GUIs) where desktop environments handle LED states, setleds remains a fundamental tool for system administrators and users working directly with the Linux kernel's console subsystem. It is part of the kbd package, which provides various console-related utilities.

CAVEATS

setleds primarily affects text-mode virtual consoles (TTYs). In graphical environments (like X11 or Wayland), the desktop environment typically manages keyboard LED states, and setleds might not have the desired effect or its changes could be immediately overridden. Modifying LED states often requires root privileges.

USAGE EXAMPLES

Here are some common ways to use setleds:

  • To turn the Num Lock LED on: setleds -N on
  • To turn the Caps Lock LED off: setleds -C off
  • To display the current LED states: setleds -L
  • To reset LEDs to reflect the current keyboard mode (e.g., Num Lock on if active): setleds -R
  • To restore LEDs to their default power-on state (Num Lock on, others off): setleds -D

HISTORY

setleds is a long-standing utility included as part of the kbd package, which provides a collection of tools for managing the Linux console's keyboard and its associated settings. Its development is closely tied to the evolution of the Linux text-mode console, serving as a direct interface to the kernel's keyboard driver for controlling LED indicators. It has been a standard component of most Linux distributions for many years, predating the widespread use of graphical desktop environments.

SEE ALSO

Copied to clipboard