How to stop Ubuntu from changing numlock state on boot?

There is no problem in other OS. Default expected behavior for standart PC – is that you:

  • Set up NumLock initial status in the bios
  • It remains same in bootloader
  • It remains same at login screen
  • It remains same in desktop session, until you intentionally change it.

So here seems to be a problem, in some “malicious” code, that forcefully disables it, during boot. Question is: What exactly disables it? What binary? Or what source file? Can I remove it, at least locally, on my machine, in order to stop Ubuntu from changing NumLock state at boot?

Or maybe that’s a tweak, like Troubleshooting features > [V] Force disable num lock at boot, that was occasionally enabled by default?

I’ve concluded some searches, what I’ve found is that:

  • Official information is outdated. There is no such menu in Ubuntu Settings as per 18.04 LTS.
  • A couple of threads, here and there, are also not answering where does the illness seats.
  • Installing and using numlockx is a stub. Why do we need disable (initially enabled) NumLock, and then use additional software to re-enable it? Such an advice really sounds like somthing “conceptually wrong”.

Can you help to find out, where is the disease source, and how to fight it?

Asked By: xakepp35


For Ubuntu Gnome 18.04+

When you are at the login screen the user ID active is gdm (Gnome Desktop Manager). To change that profile login with your own user ID and use:

sudo -i
xhost +SI:localuser:gdm
su gdm -s /bin/bash
gsettings set org.gnome.settings-daemon.peripherals.keyboard numlock-state 'on'
gsettings set org.gnome.desktop.peripherals.touchpad tap-to-click true

For a plethora of even more options:

For Ubuntu Unity 16.04+

Install the the program numlockx:

$ sudo apt update && sudo apt install numlockx

$ numlockx -h
NumLockX 1.2
(C) 2000-2001 Lubos Lunak <>
(C) 2001      Oswald Buddenhagen <>

Usage: numlockx [on|off|toggle|status]
on     - turns NumLock on in X ( default )
off    - turns NumLock off in X
toggle - toggles the NumLock on and off in X
status - gets the NumLock status

Next step is to get it running during login screen:

$ locate 50-unity-greeter.conf

$ sudo -H gedit /usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf

At bottom of file add:

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

Save file and login again.

Catchall when everything fails

Install numlockx as show above. Then

$ sudo -H gedit /etc/rc.local

At bottom of file add:

/usr/bin/numlockx on

Save file and reboot.

Answered By: WinEunuuchs2Unix

Ubuntu 20:

All the same reasoning applies but the specific key/values have changed

org.gnome.desktop.peripherals.keyboard remember-numlock-state true
org.gnome.desktop.peripherals.keyboard numlock-state false
Answered By: waiting4op2deliver

I actually wanted to disable numlock but this may well also force the enable situation as well.

I installed numlockx by running:

sudo apt install numlockx

and set the default status in /etc/default/numlockx:

# Configuration file for numlockx

# State of numlog on start of X session
# Accepts following options:
#  auto - turns numlock on unless ran on laptop
#  on - turns numlock on
#  off - turns numlock off
#  keep - does not change numlock state
#  toggle - toggles numlock state

A sledgehammer approach but worked.

Answered By: jonhind