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
- PlatformsUbuntu 26.04 LTS + AlmaLinux 10.2
- TimeAbout 24 min
- RPM packagingrpm 4.19.1.1, dnf 4.20.0
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| LPIC1-A01 | 192.168.0.76 | Ubuntu 26.04 LTS | Debian-family host - dpkg and apt, which objective 102.4 names | 2 Core | 4 GB | 50 GB |
| LPIC1-B01 | 192.168.0.77 | AlmaLinux 10.2 | RPM-family host - rpm and dnf, which objective 102.5 names | 2 Core | 4 GB | 50 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.
- reading the current locale and finding the file each family sets it in
- listing installed locales and knowing why the two families differ so much
- stating the LANG, LC_*, LC_ALL precedence and demonstrating it
- recognising the sort-order change as the reason a script is not portable
- counting the bytes a character takes in UTF-8 against a single-byte encoding
- converting between encodings with
iconv, including when it cannot
Before you start
- time-synchronisation-and-the-system-clock
-
What the machine thinks it is
-
What is actually installed
-
Three variables, and which one wins
-
The trap that breaks scripts
-
Bytes, and the encoding that interprets them
-
Putting the machine back