LinuxCommandLibrary

eselect-locale

Set system-wide locale settings

TLDR

List available locales

$ eselect locale list
copy

Set the LANG environment variable in /etc/profile.env by name or index from the list command
$ eselect locale set [name|index]
copy

Display the value of LANG in /etc/profile.env
$ eselect locale show
copy

SYNOPSIS

eselect locale <command> [<arguments>]

Common commands:
eselect locale list
eselect locale set <number or locale_name>
eselect locale show

PARAMETERS

list
    Lists all available locales recognized by the system, along with their corresponding selection numbers.

set <number or locale_name>
    Sets the active system-wide locale. You can specify either the numerical index from the list command or the full locale name (e.g., en_US.UTF-8).

show
    Displays the currently configured system locale settings.

help
    Shows usage information and available subcommands for eselect locale.

DESCRIPTION

eselect-locale is a utility primarily used in Gentoo Linux systems to manage the system's locale settings.

It provides a user-friendly interface to select and configure the desired locale for the entire system. Locales define language, country, and character encoding preferences, influencing how programs display dates, times, currencies, and text.

eselect-locale works by presenting a list of available locales (which must first be generated, typically via locale-gen) and allowing the user to choose one as the default. This selection is then persistently configured, usually by updating environment files like /etc/env.d/02locale or /etc/locale.conf, ensuring that the chosen locale is loaded upon system boot or login. It simplifies what could otherwise be a manual configuration of LANG and LC_* environment variables. It interacts with the eselect framework, which is designed to manage various system-wide "selections" or "alternatives."

CAVEATS

Limitations and Considerations:
eselect-locale is primarily available and useful on Gentoo Linux and other Portage-based distributions.
Locales must first be generated using the locale-gen command after uncommenting desired locales in /etc/locale.gen.
Changes made by eselect locale typically require a re-login or system reboot for all applications and processes to fully adopt the new locale.
Incorrect locale settings can lead to display issues (e.g., 'mojibake' for non-ASCII characters) or incorrect date/time/currency formatting in applications.

LOCALE GENERATION PREREQUISITE

Before eselect locale can be effectively used, the desired locales must be uncommented in the /etc/locale.gen configuration file. Subsequently, the locale-gen command must be executed to generate the necessary locale data files. Without this step, eselect locale list will show limited options, and setting a non-generated locale will not work correctly.

IMPACT ON ENVIRONMENT VARIABLES

The locale chosen with eselect locale set is typically persisted by writing to files within /etc/env.d/ (e.g., /etc/env.d/02locale) or similar system-wide configuration directories. These files are sourced during the system's initialization or user login process, setting crucial environment variables like LANG, LC_ALL, LC_CTYPE, LC_TIME, etc., which dictate the system's linguistic and regional behavior for all applications.

HISTORY

The eselect framework, including its locale subcommand, is an integral part of the Gentoo Linux distribution's system configuration toolkit. Developed to provide a standardized, user-friendly way to manage various system-wide "alternatives" or "selections," eselect-locale specifically emerged to streamline locale management. It integrates deeply with Gentoo's philosophy of user configurability and system transparency, evolving alongside the distribution to remain a core utility for managing linguistic and regional settings.

SEE ALSO

locale(1), locale-gen(8), localectl(1), env(1), eselect(1)

Copied to clipboard