I like to use the numeric keypad for entering long numbers. To that end, I would prefer to have X11 turn on Num Lock by default. Luckily I'm not the only one who feels that way. Chua Wen Kiat has been kind enough to provide an easy way to invoke Martin-Éric Racine's numlockx utilities at the start of a new X11 session.
We're going to download the numlockx package. Then we'll back up the system file we'll be editing and open it.
sudo apt-get install numlockx
sudo cp /etc/X11/gdm/Init/Default /etc/X11/gdm/Init/Default.bak
sudo gedit /etc/X11/gdm/Init/Default
The last line of the file should read exit 0. Just above that line, we're going to add the following.
if [ -x /usr/bin/numlockx ]; then
Save the edited file. If you want the change to take effect immediately, close all applications and enter the command sudo /etc/init.d/gdm restart, which will restart GNOME.
Please note that for reasons unknown to me the above command does not work as expected on some systems. Mine is one of them. If the command kills GNOME but fails to restart it, you could enter sudo reboot from the console or switch back to the console where X11 was running (Ctrl+Alt+F7) and reboot from there (Ctrl+Alt+Del). You may also be able to start a new session with the command startx -- :consolenumber, where consolenumber is the number of an unused console. In any case, Num Lock should now turn on at the beginning of each new session.