locale
Show current locale settings
TLDR
List all global environment variables describing the user's locale
List all available locales
Display all available locales and the associated metadata
Display the current date format
SYNOPSIS
locale [OPTION...]
locale -a
locale -k KEYWORD
locale -c CATEGORY
locale -m
PARAMETERS
-a, --all-locales
Displays a list of all locales currently available on the system. These are typically compiled and installed from locale definition files.
-c, --category=NAME
Shows the values for a specific locale category (e.g., LC_CTYPE, LC_NUMERIC). When used without a keyword, it displays all keywords for that category.
-k, --keyword=KEYWORD
Outputs the value of a specific locale keyword (e.g., decimal_point, thousands_sep). This allows querying individual locale properties.
-m, --locale-archive
Generates the locale archive file, often used in conjunction with localedef for system-wide locale compilation. This is generally a system administration task.
-v, --verbose
Provides more detailed output, showing how locale values are determined, including the environment variables influencing them.
--help
Displays a help message with usage information and exits.
--version
Shows the version information for the locale command and exits.
DESCRIPTION
The locale command is a fundamental utility for managing and querying the internationalization and localization settings on a Linux system. It allows users and applications to adapt to different linguistic and cultural conventions, such as character encoding, date and time formats, currency symbols, numerical representations, and collation rules.
When executed without options, locale displays the current settings for all active locale categories, which are primarily controlled by environment variables like LANG, LC_ALL, and individual LC_* variables (e.g., LC_CTYPE for character handling, LC_TIME for time formats).
By providing specific options, locale can list all available locales installed on the system, show the values associated with particular locale keywords, or verify the validity of locale settings. This command is crucial for ensuring that applications behave correctly according to the user's regional preferences, providing a consistent and localized user experience across the operating system.
CAVEATS
Locale Generation: While locale displays information, setting up new locales or modifying existing ones often requires generating them using localedef or a system-specific tool like locale-gen. Incorrectly generated or missing locale data can lead to errors or unexpected application behavior.
Environment Variable Precedence: The effective locale is determined by a strict precedence: LC_ALL > specific LC_* variables > LANG. Misunderstanding this can lead to surprising locale settings.
Application Support: Not all applications fully support or correctly interpret locale settings. Some older or simpler programs might ignore them, while others might require specific fonts or character sets to display correctly.
Performance Impact: Loading large locale definitions can sometimes have a minor performance impact on application startup, especially if the locale archive is not optimized or frequently regenerated.
LOCALE CATEGORIES AND PRECEDENCE
The locale settings are organized into several categories, each controlled by a specific LC_ environment variable. The locale command, when run without arguments, shows the values for these:
LC_CTYPE: Character classification and conversion (e.g., character encoding, uppercase/lowercase conversion).
LC_NUMERIC: Non-monetary numeric formatting (e.g., decimal point, thousands separator).
LC_TIME: Date and time formatting (e.g., month names, date order, 12/24-hour clock).
LC_COLLATE: String collation (sorting) order.
LC_MONETARY: Monetary formatting (e.g., currency symbol, positive/negative format).
LC_MESSAGES: Format of informative and diagnostic messages, and yes/no responses.
LC_PAPER: Paper size (e.g., A4, letter).
LC_NAME: Name format.
LC_ADDRESS: Address format.
LC_TELEPHONE: Telephone number format.
LC_MEASUREMENT: Measurement units (e.g., metric, imperial).
LC_IDENTIFICATION: Information about the locale.
The LANG variable sets the default locale for all categories not explicitly set by an LC_ variable. The LC_ALL variable overrides all other LC_ and LANG settings, providing a strong override for all locale aspects. The precedence is LC_ALL > LC_* > LANG.
HISTORY
The concept of "locale" in Unix-like systems dates back to the early 1990s, driven by the increasing need for internationalization (I18n) and localization (L10n) support in computing. The POSIX standard (IEEE Std 1003.1) formalized the locale concept to allow applications to adapt to cultural and linguistic conventions.
The locale utility itself is part of the GNU C Library (glibc) internationalization efforts. Its development reflects the evolution of glibc's comprehensive support for various character sets, collation rules, monetary formats, and other culturally sensitive data. It provides a standard way for users and system administrators to inspect and manage these settings, moving beyond simple ASCII-only environments to truly globalized computing. The command continues to be a core component in modern Linux distributions, ensuring that applications can correctly represent and process information for users worldwide.


