Configuring System Language (Locale) and Keyboard Settings

System-wide preferences for language and keyboard are stored in the locale configuration file (/etc/locale.conf). You can query and change these settings as needed using localectl command. Note that the systemd process reads the locale configuration file at boot and applies these settings to every system-wide service, user interface, and user profile, unless they're overridden by other programs or users. For more information about configuring these system-wide settings, see:

Note:

System-wide preferences for language and keyboard are also configurable during installation. For details on how to configure these settings at installation, see Oracle Linux 8: Installing Oracle Linux.

Changing the Language Setting

The system locale language setting defines the language in which text appears in the Linux user interfaces (text-based and graphical).

To query and change the language setting on the system, follow these steps:

  1. To check the current language locale set on the system, type:
    localectl status

    For example, the following system language locale output indicates: English (en) as the language, US as the country code, and UTF-8 as the codeset.

     System Locale: LANG=en_US.UTF-8       
  2. To list all possible language locales available on the system, type:
    localectl list-locales

    To search the output for a specific language locale, use the grep command. For example, to list all possible English locales available for configuration, type:

    localectl list-locales | grep en
  3. To set the default language locale on the system, type:
    sudo localectl set-locale LANG=locale_name

    Where:

    • locale_name is replaced with the name retrieved earlier from the list-locales output.
    For example, to set British English as the system language locale, type:
    sudo localectl set-locale LANG=en_GB.utf8

    Note:

    Locale options are typically listed in the following format: LANGUAGE_COUNTRY.CODESET[@MODIFIERS]. The LANGUAGE is an ISO 639 language code, for example, en for English and COUNTRY is an ISO 3166 country code. The two letter country code in this example is GB for Great Britain and the United Kingdom. The CODESET is the character set or encoding, for example, utf-8.
    For more information on how to configure language locale options on the system, see the locale manual page.

Installing Language Locales Individually

A langpack is a metapackage that consists of dependencies that provide support for a specified language. The dependencies include packages for locales, fonts, and other functionality for using a language on a system.

For a given language, one of the dependencies the langpack installs is glibc-langpack-<locale_code>. To reduce storage space required for languages, you can choose to install only the individual glibc locale langpack packages (glibc-langpack-<locale_code>).

  1. To list all language packs already installed on the system and all language packs available on the ol8_appstream repository, type:
    sudo dnf list langpacks-*
    For example, the following shows that this system has Spanish, French, Japanese, and Russian language packs installed followed by a truncated list of language packs available on ol8_appstream.
    sudo dnf list langpacks-*
    Last metadata expiration check: 1:37:24 ago on Thu 18 Apr 2024 08:14:05 AM EDT.
    Installed Packages
    langpacks-es.noarch                    1.0-12.el8                 @ol8_appstream
    langpacks-fr.noarch                    1.0-12.el8                 @ol8_appstream
    langpacks-ja.noarch                    1.0-12.el8                 @ol8_appstream
    langpacks-ru.noarch                    1.0-12.el8                 @ol8_appstream
    Available Packages
    langpacks-af.noarch                    1.0-12.el8                 ol8_appstream 
    langpacks-am.noarch                    1.0-12.el8                 ol8_appstream 
    langpacks-ar.noarch                    1.0-12.el8                 ol8_appstream 
    ...
  2. Use dnf to install a language pack. For example, the following installs the Japanese language pack:
    sudo dnf install langpacks-ja.noarch
  3. To list all installed and all available glibc Langpack packages, run the following command:
    sudo dnf list glibc-langpack*
  4. To install a glibc language pack, run the following command:
    sudo dnf install glibc-langpack-language_code

    In the previous command, language_code is the language code you want to install. For example, the following example installs Japanese.

    sudo dnf install glibc-langpack-ja.x86_64

Changing the Keyboard Layout

The keyboard layout settings enable you to specify a keymap locale for the Linux user interfaces (text-based and graphical).

To query and change the keyboard layout settings on the system, follow these steps:

  1. To check the current keyboard layout configuration on the system, type:
    localectl status
    For example, the following keyboard layout output indicates a US country code for the virtual console keymap and a US country code for the X11 layout.
     System Locale: LANG=en_US.UTF-8
           VC Keymap: us
          X11 Layout: us
    
  2. To list all possible keyboard layout configurations available, type:
    localectl list-keymaps

    To search the output for a specific keymap name, use the grep command. For example, to list British compatible keyboard layouts, type:

    localectl list-keymaps | grep gb
  3. To set the default keyboard layout on the system, type:
    sudo localectl set-keymap keymap_name

    Where:

    • keymap_name is replaced with the name of the keymap retrieved earlier from the list-keymaps output.
    Note that the keymap name change applies to both the virtual console and the x11 layout settings. If you want the X11 layout to differ from the virtual console keymap, use the --no-convert option, for example:
    sudo localectl --no-convert set-x11-keymap keymap_name

    The no-convert option retains the previous x11 keyboard layout setting.

    For more information on how to use the localectl command line utility to change keyboard system settings, see thelocalectl manual page.