Hands-on steps to compile, enable and manage locale definitions on Linux using localedef and locale-gen. 16.11.2025 | reading time: 3 min Want numbers, dates and currency formatted exactly the way a system requires? This guide shows how to compile new locales with `localedef`, enable distribution-provided locales with `locale-gen`, and set the system default with `localectl` so programs pick up the new definitions. Build and enable locales Follow these exact commands to rebuild a locale, enable a new one on Debian-style systems and set the system default; the code block shows commands and a quick verification: ```bash # Rebuild en_US with UTF-8 sudo localedef -v -c -i en_US -f UTF-8 en_US.UTF-8 # Enable fr_FR and generate locales (append to /etc/locale.gen then generate) sudo bash -c "echo 'fr_FR.UTF-8 UTF-8' >> /etc/locale.gen" sudo locale-gen # Set system locale with systemd sudo localectl set-locale LANG=fr_FR.UTF-8 # Verify compiled locales locale -a ``` Where locale sources and binaries live Locales are built from source files in `/usr/share/i18n/locales` and charmaps in `/usr/share/i18n/charmaps`; compiled locales end up in the system locale archive (commonly `/usr/lib/locale` or the glibc locale-archive) and `locale -a` lists available locales. Options that matter When invoking `localedef` the key flags are `-i` for the input source, `-f` for the character map, `-v` for verbose and `-c` to continue on warnings; use the exact output name format `language[_territory][@modifier].codeset` and note that ICU-managed locales are separate from glibc locales. Practical use cases Rebuild a broken locale after glibc upgrades, create a minor variant for a specific application by copying and editing a locale source then compiling it, or enable additional languages on a server image by appending lines to `/etc/locale.gen` and running `locale-gen` in an automated provisioning script. Tools that play well together For system-wide changes use `localectl` to persist the choice; inspect current settings with the `locale` command; and convert data between encodings with `iconv` when migrating text to a newly compiled locale. Finish line Compiling and enabling locales gives predictable formatting for dates, times, numbers and messages across software stacks; explore more, practice the commands on a test VM and consider formalizing the skill with certifications and intensive exam prep at bitsandbytes.academy. Join Bits & Bytes Academy First class LINUX exam preparation. setup utilities scripting