Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like turn on/turn off some of my leds running a command on linux.

I use Ubuntu 12.04 LTS.

I tried

xset led named "Scroll Lock"
xset led named "Num Lock"
xset led 2             (this is the number of Scroll Lock as `xset q` says)
xset led 1

but nothing works.


setleds +num
setleds +scroll

but I got a error message saying Error reading the current settings of flags. Maybe you're not on the console? (I was in a terminal).

So, how can I perform this?

share|improve this question

Install xf86-input-keyboard if you don't have it.

Set kbd_mode -u

Make sure you don't have multiple instances of the KB (check what XINPUT: reports).

share|improve this answer

To turn Scroll Lock led on run:

xset -led 2 led on

To turn it off run:

xset -led 2 led off
share|improve this answer

Just use the command:

numlockx on 


numlockx off

to change the state.

share|improve this answer
This is rather brief: some more detail would be helpful. For example, in what circumstances does this command work? – David Richerby Apr 30 '15 at 10:33
It does exactly what it sounds like. – Frankie Apr 30 '15 at 20:08

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

share|improve this answer
This should be the accepted answer. Best solution I've ever seen. Thank you! The lights are so annoying! – jocap May 13 '14 at 21:22

Press Ctrl+Alt+F1, login, and then try setleds.

share|improve this answer
Interesting. setleds (not xset) worked for me now too. Looks like we need set a display. I tried several things but nothing worked. But, looks we're almost. – GarouDan Jun 17 '12 at 11:28
Please accept as answer if solved – VenkatH Jul 22 '12 at 18:58
This isnt the final answer to me, because I need this working on the gui display, not at the console display. – GarouDan Jul 23 '12 at 19:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.