System Locale and Keyboard Configuration

The system locale specifies the language settings of system services and user interfaces. The keyboard layout settings control the layout used on the text console and graphical user interfaces.

These settings can be made by modifying the /etc/locale.conf configuration file or by using the localectl utility. You can also set these settings during system installation using the installer graphical interface, text mode interface, or the keyboard and lang Kickstart commands. See the link:https://docs.fedoraproject.org/en-US/fedora/fFedora 40/install-guide[Fedora Installation Guide] for information about these options.

Configurando a Localidade do Sistema

As configurações de localidade de todo o sistema são armazenadas no arquivo /etc/locale.conf, que é lido na inicialização inicial pelo daemon systemd. As configurações de localidade configuradas em /etc/locale.conf são herdadas por cada serviço ou usuário, a menos que programas individuais ou usuários individuais as substituam.

O formato de arquivo básico /etc/locale.conf é uma lista de atribuições de variáveis separadas por nova linha. Por exemplo, a localidade alemã com mensagens em inglês em /etc/locale.conf tem a seguinte aparência:

LANG=de_DE.UTF-8
LC_MESSAGES=C

Aqui, a opção LC_MESSAGES determina a localidade usada para mensagens de diagnóstico gravadas na saída de erro padrão. Para especificar ainda mais as configurações de localidade em /etc/locale.conf, você pode usar várias outras opções, as mais relevantes estão resumidas em Opções configuráveis em /etc/locale.conf. Veja a página de manual do locale(7) para informações detalhadas sobre essas opções. Note que a opção LC_ALL, que representa todas as opções possíveis, não deve ser configurada em /etc/locale.conf.

Tabela 1. Opções configuráveis em /etc/locale.conf
Opção Descrição

LANG

Fornece um valor padrão para a localidade do sistema.

LC_COLLATE

Altera o comportamento das funções que comparam strings no alfabeto local.

LC_CTYPE

Altera o comportamento das funções de manipulação e classificação de caracteres e das funções de caracteres multibyte.

LC_NUMERIC

Descreve a forma como os números são normalmente impressos, com detalhes como ponto decimal versus vírgula decimal.

LC_TIME

Altera a exibição da hora atual, relógio de 24 horas versus relógio de 12 horas.

LC_MESSAGES

Determina a localidade usada para mensagens de diagnóstico gravadas na saída de erro padrão.

Exibindo o Status Atual

O comando localectl pode ser usado para consultar e alterar a localidade do sistema e as configurações de layout do teclado. Para mostrar as configurações atuais, use a opção status:

localectl status
Exemplo 1. Exibindo o Status Atual

A saída do comando anterior lista a localidade atualmente definida, o layout do teclado configurado para o console e para o sistema de janelas X11.

~]$ localectl status
   System Locale: LANG=en_US.UTF-8
       VC Keymap: us
      X11 Layout: n/a

Listando Localidades Disponíveis

Para listar todas as localidades disponíveis para seu sistema, digite:

localectl list-locales
Exemplo 2. Listando Localidades

Imagine que você deseja selecionar uma localidade específica em Inglês, mas não tem certeza se ela está disponível no sistema. Você pode verificar isso listando todas as localidades em Inglês com o seguinte comando:

~]$ localectl list-locales | grep en_
en_AG
en_AG.utf8
en_AU
en_AU.iso88591
en_AU.utf8
en_BW
en_BW.iso88591
en_BW.utf8

output truncated

Configurando a Localidade

Para definir a localidade padrão do sistema, use o seguinte comando como root:

localectl set-locale LANG=localidade

Substitua localidade pelo nome da localidade, encontrado com o comando localectl list-locales. A sintaxe acima também pode ser usada para configurar parâmetros de Opções configuráveis em /etc/locale.conf.

Exemplo 3. Changing the Default Locale

For example, if you want to set British English as your default locale, first find the name of this locale by using list-locales. Then, as root, type the command in the following form:

~]# localectl set-locale LANG=en_GB.utf8

Changing the Keyboard Layout

The keyboard layout settings enable the user to control the layout used on the text console and graphical user interfaces.

Displaying the Current Settings

As mentioned before, you can check your current keyboard layout configuration with the following command:

localectl status
Exemplo 4. Displaying the Keyboard Settings

In the following output, you can see the keyboard layout configured for the virtual console and for the X11 window system.

~]$ localectl status
   System Locale: LANG=en_US.utf8
       VC Keymap: us
      X11 Layout: us

Listing Available Keymaps

To list all available keyboard layouts that can be configured on your system, type:

localectl list-keymaps
Exemplo 5. Searching for a Particular Keymap

You can use grep to search the output of the previous command for a specific keymap name. There are often multiple keymaps compatible with your currently set locale. For example, to find available Czech keyboard layouts, type:

~]$ localectl list-keymaps | grep cz
cz
cz-cp1250
cz-lat2
cz-lat2-prog
cz-qwerty
cz-us-qwertz
sunt5-cz-us
sunt5-us-cz

Configurando o Mapa de Teclas

To set the default keyboard layout for your system, use the following command as root:

localectl set-keymap map

Replace map with the name of the keymap taken from the output of the localectl list-keymaps command. Unless the --no-convert option is passed, the selected setting is also applied to the default keyboard mapping of the X11 window system, after converting it to the closest matching X11 keyboard mapping. This also applies in reverse, you can specify both keymaps with the following command as root:

localectl set-x11-keymap map

If you want your X11 layout to differ from the console layout, use the --no-convert option.

localectl --no-convert set-x11-keymap map

With this option, the X11 keymap is specified without changing the previous console layout setting.

Exemplo 6. Setting the X11 Keymap Separately

Imagine you want to use German keyboard layout in the graphical interface, but for console operations you want to retain the US keymap. To do so, type as root:

~]# localectl --no-convert set-x11-keymap de

Then you can verify if your setting was successful by checking the current status:

~]$ localectl status
   System Locale: LANG=de_DE.UTF-8
       VC Keymap: us
      X11 Layout: de

Apart from keyboard layout (map), three other options can be specified:

localectl set-x11-keymap map model variant options

Replace model with the keyboard model name, variant and options with keyboard variant and option components, which can be used to enhance the keyboard behavior. These options are not set by default. For more information on X11 Model, X11 Variant, and X11 Options see the kbd(4) man page.

Consider this option if using gnome

This should work if the following conditions apply:

  • Using gnome as the desktop environment

  • Your layout is not listed under Settings → Keyboard → Input Sources

In your terminal type in:

gsettings set org.gnome.desktop.input-sources show-all-sources true

after pressing return, try looking under your keyboard settings again as there should be a lot more options available. As the proper source for help is gnome in this case, here is more information from gnome:

Additional Resources

For more information on how to configure the keyboard layout on Fedora, see the resources listed below:

Installed Documentation
  • localectl(1) — The manual page for the localectl command line utility documents how to use this tool to configure the system locale and keyboard layout.

  • loadkeys(1) — The manual page for the loadkeys command provides more information on how to use this tool to change the keyboard layout in a virtual console.