From modern Kali to legacy metasploitable: mastering ABNT2 keyboard layouts on Linux via CLI
Back to blog

From modern Kali to legacy metasploitable: mastering ABNT2 keyboard layouts on Linux via CLI

10/25/2026 · 3 min · Linux

The ABNT2 puzzle: when /, ?, and ç stop working between Kali and Metasploitable2#

Working with security labs frequently requires pivoting between bleeding-edge environments and legacy virtual machines. During hands-on sessions, missing keys like /, ?, or ç on Brazilian ABNT2 keyboards can quickly interrupt your workflow.

The technical challenge was configuring the ABNT2 layout purely through the command line across two radically different systems: modern Kali Linux and legacy Metasploitable2.

Achieving persistent configurations requires understanding how Linux processes input events across different system layers.


1. Linux input layers: TTY console vs. X11 desktop#

Keypress signals travel through distinct subsystems depending on the execution context:

  1. Virtual Console (TTY): The Linux kernel translates hardware scancodes directly to keycodes via tables loaded in kernel memory.
  2. Graphical Environment (X11 / Desktop): The X Server manages the XKB subsystem (/usr/share/X11/xkb), intercepting input events before delivering them to graphical applications.
  3. Boot Persistence: Where system initialization daemons (systemd, SysVinit, or udev) retrieve parameters on startup.

2. Configuring modern Kali Linux (X11 & systemd)#

Kali Linux is built on a modern Debian base running systemd and an XFCE/X11 desktop.

Immediate runtime update (active session)#

To apply ABNT2 instantly in the active X11 desktop session:

setxkbmap br

Mechanism: setxkbmap sends X11 protocol calls to load key symbols from /usr/share/X11/xkb/symbols/br.

Persistent configuration across reboots#

To persist the layout across both console and graphical sessions:

sudo dpkg-reconfigure keyboard-configuration
  1. Select standard keyboard hardware (Generic 105-key PC).
  2. Choose Other -> Portuguese (Brazil).
  3. Select Portuguese (Brazil, ABNT2).

This utility updates /etc/default/keyboard, loaded automatically during system boot.


3. Configuring legacy metasploitable2 (Ubuntu 8.04 / kernel 2.6)#

Metasploitable2 is based on legacy Ubuntu 8.04 without systemd and operates almost exclusively in text-mode virtual consoles (TTY).

Immediate console update (TTY runtime)#

To load the Brazilian keymap into the active virtual console:

sudo loadkeys br-abnt2

Mechanism: loadkeys executes an ioctl system call loading the binary keymap directly into the kernel console driver (/dev/tty0).

Boot persistence on metasploitable2#

On Ubuntu 8.04, persistence is managed in /etc/default/console-setup:

sudo nano /etc/default/console-setup

Configure the target variables:

XKBLAYOUT="br"
XKBVARIANT="abnt2"

Apply the changes by restarting the legacy console service:

sudo /etc/init.d/console-setup restart

4. Diagnostics and virtualization edge cases#

If specific keys fail after configuration:

A. Raw hardware scancode inspection (showkey)#

To inspect raw hardware scancodes reaching the kernel console:

showkey -s

B. The SSH terminal trap#

When managing Kali or Metasploitable2 over SSH, commands like setxkbmap or loadkeys have zero effect.

In SSH sessions, keyboard mapping occurs entirely within your local terminal emulator (Kitty, Alacritty, GNOME Terminal, PuTTY). The remote server receives pre-translated UTF-8 character bytes. Guest CLI mapping commands only affect direct virtual machine display consoles.


Quick reference matrix#

EnvironmentLayer / SubsystemRuntime CommandPersistent Configuration
Kali LinuxX11 / Modern Desktopsetxkbmap brsudo dpkg-reconfigure keyboard-configuration
Metasploitable2TTY Console (Kernel 2.6)sudo loadkeys br-abnt2/etc/default/console-setup + service restart

Understanding the distinction between kernel console keymaps and X11 symbols ensures reliable keyboard navigation across modern and legacy Linux lab environments.

Was this article helpful?

Leave a quick reaction to help prioritize future technical guides:

CC BY-NC

This post is licensed under CC BY-NC.

Comments

Join the discussion below.

0 comments