CertGrid CertGrid
Hands-on Lab·LPIC-1

Locale, encoding, and what changes with it

Objective 107.3 covers locale and character encoding. This guide finds what each family has installed and where it is configured, proves the LANG / LC_* / LC_ALL precedence chain with three runs of the same command, shows the sort-order change that silently breaks scripts, and converts a file between encodings a byte at a time.

102: Administrative Tasks Guide 32 of 33 Intermediate

Both families. The locale demonstrations run on the RPM host because it has 885 locales installed and the Debian host has four, all English.
Server NameIP AddressOSRolesCPURAMHDD
LPIC1-A01192.168.0.76Ubuntu 26.04 LTSDebian-family host - dpkg and apt, which objective 102.4 names2 Core4 GB50 GB
LPIC1-B01192.168.0.77AlmaLinux 10.2RPM-family host - rpm and dnf, which objective 102.5 names2 Core4 GB50 GB

This guide includes

Use this when a script behaves differently on another machine, when sorted output or a comparison is not what you expect, or when text arrives as mojibake. This matters because the locale changes what commands like sort and printf do without any of them being reconfigured.

Before you start

  1. What the machine thinks it is

  2. What is actually installed

  3. Three variables, and which one wins

  4. The trap that breaks scripts

  5. Bytes, and the encoding that interprets them

  6. Putting the machine back

Official sources