LinuxCommandLibrary

locale

Show current locale settings

TLDR

List all global environment variables describing the user's locale

$ locale
copy

List all available locales
$ locale [[-a|--all-locales]]
copy

Display all available locales and the associated metadata
$ locale [[-a|--all-locales]] [[-v|--verbose]]
copy

Display the current date format
$ locale date_fmt
copy

SYNOPSIS

locale [OPTION]... [NAME]...

PARAMETERS

-a, --all-locales
    Display a list of all supported locales.

-m, --charmap
    Display the character map being used.

-v, --verbose
    Display verbose information about each locale.

-k, --keyword
    With -a, show the possible values for the given keyword

[NAME]
    Specify a locale variable to display its value. If none is provided, all locale variables are displayed.

--help
    Display help message and exit.

--version
    Display version information and exit.

DESCRIPTION

The `locale` command in Linux displays information about the current locale settings of the system or allows modifying locale related variables. The locale affects how programs handle language-specific settings like character encoding, date and time formats, currency symbols, and sorting orders. Understanding the locale is crucial for ensuring that applications correctly display and process text and data according to regional conventions.
Without any options, `locale` displays the current values of all locale variables. You can specify specific locale variables (e.g., `LC_TIME`, `LANG`, etc.) as arguments to display only their values. The `locale` command is a fundamental tool for internationalization (i18n) and localization (l10n), enabling software to adapt to different languages and regional preferences. It is commonly used in scripts and applications to configure the environment for specific language or cultural settings. Note that modifying the system locale often requires root privileges, especially when changing system-wide settings.

CAVEATS

Changing the locale system-wide often requires root privileges. Changes might not take effect immediately and may require a logout/login or restarting the affected services.

LOCALE VARIABLES

Common locale variables include:
LANG: Overall locale setting.
LC_CTYPE: Character classification and case conversion.
LC_NUMERIC: Numeric formatting.
LC_TIME: Date and time formatting.
LC_COLLATE: Collation (sorting) order.
LC_MONETARY: Monetary formatting.
LC_MESSAGES: Message translation.
LC_ALL: Overrides all other LC_* variables and LANG. Using `LC_ALL` is discouraged.

EXAMPLES

Displaying all locale variables: `locale`
Displaying the value of LC_TIME: `locale LC_TIME`
Listing all supported locales: `locale -a`

SEE ALSO

localedef(1), update-locale(8)

Copied to clipboard