How to turn on/off leds by terminal?

Solution 1:

xdotool key Num_Lock

Is the an answer (the easiest you're likely to find); inverting the state, it also provides a path to search (xinput and modifying a slave keyboard state) if you really just want to set an led status.

I too ran across my Num Lock keyboard LED and X11 state differing recently (happens with remote desktops, games, etc)

This reference explains what's going on, and almost has the complete solution (but it has a case-typo, you need Num_Lock not Num_lock).

http://blog.ssokolow.com/archives/2013/04/18/how-to-invert-your-x11-numlock-led/

Solution 2:

To turn Scroll Lock led on run:

xset -led 2 led on

To turn it off run:

xset -led 2 led off

Solution 3:

There is also solution without any extra software. Just use:

echo "1" > /sys/class/leds/input20::scrolllock/brightness
#Or
echo "1" > /sys/class/leds/input20::/brightness

as root.