Enable NumLock Key for TTY During Boot Process on Linux

Enable NumLock Key for TTY During Boot Process on Linux

In the context of Linux systems, TTY commonly refers to virtual consoles. These are interfaces that allow users to interact with the system through text commands and perform various system tasks without a graphical user interface (GUI). For Linux users who prefer the NumLock key to be enabled by default when the system boots up to a TTY, manually toggling it every time could be inconvenient. This tutorial explains how to enable NumLock key for TTY during boot process on Linux.

The commands presented in the post are applicable for Linux distributions that utilize systemd, such as Ubuntu, Debian, and similar systems.

The first step is to create a directory structure for systemd to include additional configuration for the getty service. Open the terminal and enter the following command:

sudo mkdir -p /etc/systemd/system/getty@.service.d

Now, let's create a configuration file within the newly created directory. This file will contain the instructions to enable NumLock:

FILE=/etc/systemd/system/getty@.service.d/enable-numlock.conf
echo '[Service]' | sudo tee -a $FILE
echo "ExecStartPre=/bin/bash -c 'setleds -D +num < /dev/%I'" | sudo tee -a $FILE

These commands create a configuration file named enable-numlock.conf and add the necessary content to it. The setleds command is used to control the keyboard LEDs, and in this case, it ensures that NumLock is activated before the getty service starts.

With these steps completed, NumLock should now be enabled by default when the system boots up to a TTY. This small tweak can be especially useful for users who frequently work in text terminals.

Leave a Comment

Cancel reply

Your email address will not be published.