Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to force numlock to be on upon initial boot at the login screen on Ubuntu 12.04. The only solutions I have found so far switch numlock on only after initial login.

I'm looking to force numlock to be on when the login screen is displayed, and before the user has logged in. Can anyone assist?

share|improve this question
    
is it during login screen on lightdm or after logging in under unity? cause i know solution to both –  sarveshlad May 2 '12 at 17:11
    
From darryn.ten -- NOT an exact duplicate, as I need numlock on BEFORE I login not after. –  Jjed Jul 24 '12 at 21:58

7 Answers 7

up vote 21 down vote accepted

On many machines, you can set whether or not Number Lock is turned on on boot, in the BIOS settings (accessible when you first power on the machine).

Otherwise, there are a number of ways to enable (or disable) Number Lock in software, depending on your specific needs. The most useful ways are listed here.

If you want Number Lock turned on when Ubuntu starts (not before that on the GRUB menu, and not afterwards when logging in, and not just for specific virtual consoles), then install numlockx and make the initialization script /etc/rc.local use it to enable Number Lock:

sudo apt-get update
sudo apt-get -y install numlockx
sudo sed -i 's|^exit 0.*$|# Numlock enable\n[ -x /usr/bin/numlockx ] \&\& numlockx on\n\nexit 0|' /etc/rc.local

Source: NumLock, by Contributors to the Ubuntu documentation wiki, last line taken verbatim (as this source permits).

share|improve this answer
    
So I followed the instructions over at the wiki page you linked to. I did the update command you list here. I did sudo apt-get install numlockx. But I didn't use the y option. Is that necessary? Didn't say anything about it over at the wiki page so I didn't do any of that. I rebooted and everything but Numlock is still disabled at boot and at login screen. Will try the update command. Other than that, am I missing something else here? The option "default numeric keypad keys" from keyboard preferences doesn't concern boot settings so I didn't enable that. Should I? –  sammyg Jul 21 '13 at 13:26
1  
This did not work for me. Answer by +luvr did however. –  Clarkey Aug 24 '13 at 19:16
2  
This no longer works on Xubuntu LTS 12.04. –  Gin Gordon May 9 at 16:39

Here's what worked for me:

  1. Ensure that numlockx is installed:

    sudo apt-get install numlockx
    
  2. Edit the file /etc/lightdm/lightdm.conf

    gksudo gedit /etc/lightdm/lightdm.conf
    
  3. Add the following line to the file:

    greeter-setup-script=/usr/bin/numlockx on
    
share|improve this answer
    
How can I just verify that numlockx is installed? Should it appear on a dash search? –  sammyg Jul 21 '13 at 13:32
    
Do I have to remove greeter-session=unity-greeter or the user-session=ubuntu` from the file (lightdm.conf)? Or just the greeter-setup-script line below them? –  sammyg Jul 21 '13 at 13:35
    
Yup! This worked like a charm! Unlike the complicated instructions and commands given in the accepted answer. Thanks! I also enabled the option "default numeric keypad keys" as shown below. –  sammyg Jul 21 '13 at 13:40
2  
On Ubuntu 13.10 this method prevented the display of the login screen on my machine. After the initial display of the Ubuntu logo, the monitor was simply showing that there is no signal (I tried to reboot a couple of times but it always ended up the same). Not knowing what else to do, I booted the system from a live USB and removed the line from lightdm.conf. After that the system loaded up again just fine. –  cascaval Jan 3 at 15:57
    
@cascaval I had the same problem. What fixed it for me was installing the lightdm greeter (sudo apt-get install lightdm-gtk-greeter) then modifying the config so it used unity as before (edit /etc/lightdm/lightdm.conf and change the line to greeter-session=unity-greeter). THEN you can add the greeter-setup-script line, as described by @luvr. –  Kevin Mar 18 at 15:52

14.04

Yes, use locate command as follow:

locate 50-unity-greeter.conf

The output is:

/usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf

So, the file you need to edit is the above file.

sudo apt-get install numlockx
gksu gedit /usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf

Add this line at the end of file:

greeter-setup-script=/usr/bin/numlockx on
share|improve this answer

For Enabling it on Login Screen

First, ensure that numlockx is installed, by typing these in terminal:

sudo apt-get install numlockx

Then, edit the file /etc/lightdm/lightdm.conf

gksudo gedit /etc/lightdm/lightdm.conf

Add the following line to the file:

greeter-setup-script=/usr/bin/numlockx on

For Enabling Numlock by Default after Logging In..

  1. In Dash Search for Keyboard Layout and open it
  2. In the window that opens on the ottom right there is Options, click on it.
  3. Under Miscellaneous compatibility options, Enable Default Numeric Keys.

enter image description here

share|improve this answer
1  
it's not this case, i make this procedure by the way. I press the button "Num Lock" and immediately it's goes off, "don't stay on". I had checked the keyboard and it's ok in other machine and other o.s. I change the keyboard to an older ps/2 keyboard to test. It seems that works, ie, there is some problem with USB keyboard in ubuntu 12.04 –  Brunno May 4 '12 at 14:12

I have done this, and it worked for me. First, make sure you have universe repository added.

Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the commands below.

sudo apt-get update
sudo apt-get install numlockx

Now that numlockx is installed, create a file named Default in /etc/X11/ with these contents:

if [ -x /usr/bin/X11/numlockx ]; then
    /usr/bin/X11/numlockx on
fi

exit 0

Turn off your Num Lock and reboot. Voilà!

share|improve this answer

Most BIOSes allow this to be enabled. You can check your BIOS for this feature.

OR

Go to : System Settings -> Keyboard Layout -> Options -> Miscellaneous compatibility options

Check "Default numeric keypad keys"

Sources : https://help.ubuntu.com/community/NumLock

share|improve this answer
1  
I gave up...thanks –  신영민 Feb 12 '12 at 1:17

Here is a little bash script which takes care of everything in an automated way:

#!/bin/bash
FILE='/etc/lightdm/lightdm.conf'
KEYVALUE='greeter-setup-script=/usr/bin/numlockx on'
sudo apt-get --yes install numlockx
grep --quiet "$KEYVALUE" "$FILE" || echo "$KEYVALUE" | sudo tee --append "$FILE"

Do not forget to first make your bash script executable with chmod +x scriptname, then execute it with ./scriptname.

share|improve this answer

protected by Community Feb 16 at 9:28

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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