Where to start First steps track · 15 stages
Linux Labs

Locale and encoding

cheat sheet · Ubuntu 24.04 https://lab.dimsanych.ru/en/wiki/locale/

Cheat sheet

  • locale current settings
  • locale -a available locales
  • sudo locale-gen ru_RU.UTF-8 generate one
  • sudo update-locale LANG=en_US.UTF-8 system default (or localectl set-locale)
  • export LC_ALL=C stable output in scripts
  • LC_ALL=C sort file a one-off byte-order sort
  • localectl status the systemd view

Configuration

bash
sudo locale-gen en_US.UTF-8 ru_RU.UTF-8   # generate locales
sudo update-locale LANG=en_US.UTF-8       # the system default locale (/etc/default/locale)
# temporarily, for the current session:
export LANG=ru_RU.UTF-8

localectl status                  # the system locale (systemd)
sudo localectl set-locale LANG=en_US.UTF-8
sudo dpkg-reconfigure locales     # interactive picker (Debian/Ubuntu)

Precedence: LC_ALL (overrides everything) > specific LC_* variables > LANG (the general default).

Variable Affects
LANG the general default for all categories
LC_CTYPE encoding (UTF-8!)
LC_TIME date/time format (see date)
LC_NUMERIC the decimal separator (. or ,)
LC_COLLATE sort order (sort)
LC_ALL overrides everything (for scripts: LC_ALL=C)
Loading…