Skip to main content
Engineering LibreTexts

08-A.3: Localization - localectl Command

  • Page ID
    33166
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    The localectl Command

    In computing, a locale is a set of parameters that defines the user's language, region, and any special variant preferences that the user wants to see in their user interface. Usually a locale identifier consists of at least a language code and a country/region code.

    These settings can be made by modifying the /etc/locale.conf (although some distributions use the /etc/default/locale file) configuration file or by using the localectl utility. Also, you can use the graphical user interface to perform the task.

    System-wide locale settings are stored in the /etc/locale.conf (or /etc/default/locale) file, which is read at early boot by the systemd daemon. The locale settings configured in /etc/locale.conf are inherited by every service or user, unless individual programs or individual users override them.

    Syntax:

    localectl [ OPTIONS ] {COMMAND}
    

    As with the timedatectl command, the localectl command has typical Linux type options as well as sub-commands that specify what the command is supposed to perform.

    Sub-Commands Explanation
    status Show current settings of the system locale and keyboard mapping. If no command is specified, this is the implied default.
    set-locale LOCALE, set-locale VARIABLE=LOCALE... Set the system locale.
    list-locales List available locales useful for configuration with set-locale.
    list-keymaps List available keyboard mappings for the console, useful for configuration with set-keymap.

    The following options can be combined with the above mentioned sub-commands -examples can be found below.

    Command Options:

    Option Option Meaning
    -H, --host= Execute the operation remotely.
    --no-ask-password Do not query the user for authentication for privileged operations.
    --no-convert If set-keymap or set-x11-keymap is invoked and this option is passed, then the keymap will not be converted from the console to X11, or X11 to console, respectively.

    A couple of examples to show the usage:

    pbmac@pbmac-server $ localectl status
       System Locale: LANG=en_US.UTF-8
           VC Keymap: us
          X11 Layout: n/a
          
    to select a specific English locale, but if you are not sure if it is available 
    on the system, you can check that by listing all English locales
    pbmac@pbmac-server $ 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
    ...
    
    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:
    pbmac@pbmac-server $ localectl set-locale LANG=en_GB.utf8

    Character Sets, Coded Character Sets, and Encoding

    Historically, the terms "character encoding", "character map", "character set" and "code page" were synonymous in computer science, as the same standard would specify a repertoire of characters and how they were to be encoded into a stream of code units – usually with a single character per code unit. But now the terms have related but distinct meanings, due to efforts by standards bodies to use precise terminology when writing about and unifying many different encoding systems. Regardless, the terms are still used interchangeably, with character set being nearly ubiquitous.A character set or repertoire comprises the set of characters one might use for a particular purpose – be it those required to support Western European languages in computers, or those a Chinese child will learn at school in the third grade (nothing to do with computers).

    A coded character set is a set of characters for which a unique number has been assigned to each character. Units of a coded character set are known as code points. A code point value represents the position of a character in the coded character set. For example, the code point for the letter á in the Unicode coded character set is 225 in decimal, or 0xE1 in hexadecimal notation. (Note that hexadecimal notation is commonly used for referring to code points, and will be used here.) A Unicode code point can have a value between 0x0000 and 0x10FFFF.

    Coded character sets are sometimes called code pages.

    A "code page" usually means a byte-oriented encoding, but with regard to some suite of encodings (covering different scripts), where many characters share the same codes in most or all those code pages. Well-known code page suites are "Windows" (based on Windows-1252) and "IBM"/"DOS" (based on code page 437), see Windows code page for details. Most, but not all, encodings referred to as code pages are single-byte encodings (but see octet on byte size.)

    IBM's Character Data Representation Architecture (CDRA) designates entities with coded character set identifiers (CCSIDs), each of which is variously called a "charset", "character set", "code page", or "CHARMAP".

    The term "code page" does not occur in Unix or Linux where "charmap" is preferred, usually in the larger context of locales.

    In contrast to a "coded character set", a "character encoding" is a map from abstract characters to code words. A "character set" in HTTP (and MIME) parlance is the same as a character encoding (but not the same as CCS).

    "Legacy encoding" is a term sometimes used to characterize old character encodings, but with an ambiguity of sense. Most of its use is in the context of Unicodification, where it refers to encodings that fail to cover all Unicode code points, or, more generally, using a somewhat different character repertoire: several code points representing one Unicode character, or versa (see e.g. code page 437). Some sources refer to an encoding as legacy only because it preceded Unicode. All Windows code pages are usually referred to as legacy, both because they antedate Unicode and because they are unable to represent all 221 possible Unicode code points.

    Adapted from:
    "Chapter 2. System Locale and Keyboard Configuration" by Multiple Contributors, Fedora Docs is licensed under CC BY-SA 3.0
    "Character encoding" by Multiple ContributorsWikipedia is licensed under CC BY-SA 3.0


    08-A.3: Localization - localectl Command is shared under a CC BY-SA 4.0 license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?