System and processes

The localectl command

Shows and changes the system language and keyboard settings, for both the console and the graphical environment. It is managed by systemd, so it only exists on distributions that use it. The changes are saved in configuration files, so they survive a reboot.

Syntax

localectl [orden] [argumento]Try it in the terminal →

Most useful options

statusShows the locale, the console keymap and the X11 layout. It is the default command
list-keymapsLists all the available console keymaps
set-keymap MAPAChanges the console keymap and saves it for future boots. Requires sudo
set-locale LANG=VALORChanges the system language variable, for example LANG=es_ES.UTF-8

Copy-ready examples

$ localectl statusshows the current language and keyboard settings.

Example output

   System Locale: LANG=es_ES.UTF-8
       VC Keymap: es
      X11 Layout: es
$ sudo localectl set-keymap essets the console keyboard to Spanish and keeps it saved for good.
$ sudo localectl set-locale LANG=es_ES.UTF-8changes the system language. It is saved in /etc/locale.conf and applies to new sessions.

You can try them in the browser terminal: it does not touch your computer.

Common errors

MessageCauseFix
Failed to set keymap: Access deniedYou do not have administrator rights. set-keymap and set-locale fail without sudo.Put sudo in front of the command.
System has not been booted with systemd as init system (PID 1). Can't operate.The machine does not use systemd, so the command does not exist or does nothing.Check which tool your distribution uses for the language, for example dpkg-reconfigure on Debian.

Typical mistakes

  • A locale only works if it is generated on the system. If it is missing, applications fall back to the default language.
  • set-keymap affects the text console, not the desktop. For the graphical keyboard use set-x11-keymap.
  • Changing the language does not translate programs that are already open. It applies to new sessions.

Differences from similar commands

  • timedatectl: manages the time zone, the date and time synchronization. localectl only handles language and keyboard.
  • hostnamectl: changes the machine name and shows system data. It does not touch the language.
  • loadkeys: changes the console keyboard immediately, but does not save it for the next boot.

FAQ

What does localectl set-locale change?

The system LANG variable, saved in /etc/locale.conf. It applies to sessions opened afterwards.

Why won't it let me change the keyboard?

You lack administrator rights. Put sudo in front of the command and try again. Remember that sudo asks for your own password, not the root one.

What is the difference between the console keyboard and the X11 one?

The console uses a keymap and the graphical desktop uses the X11 layout. Changing one does not change the other. Each one has its own command.

More System and processes commands

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course