Linucate
~ Linucate_

107.3 Localisation and Internationalisation

All Levels

Introduction

This lesson is about locale and language settings.

The main question is:

How do you make Linux use the right language, character encoding, date format, and timezone, and why does that matter in scripts?

What you should be able to do after this lesson:

  • Understand LANG, LC_*, and LC_ALL.
  • Inspect locale settings with locale.
  • Understand UTF-8, ASCII, and legacy encodings at a beginner level.
  • Configure timezone settings.
  • Understand why LANG=C can be useful in scripting.

Big Idea: Locale Settings Change How Text and Time Are Interpreted

Linux does not treat all text and formatting the same way automatically.

Locale settings affect things such as:

  • language
  • sort order
  • date formatting
  • month names
  • character classification

That is why the same command output can look different on different systems.

LANG, LC_*, and LC_ALL

LANG

Default locale for the session.

LC_*

More specific category overrides, such as:

  • LC_TIME
  • LC_MESSAGES
  • LC_NUMERIC

LC_ALL

Strong override for all locale categories.

Simple beginner rule:

  • LANG = general default
  • LC_* = category-specific override
  • LC_ALL = strongest override

Inspect Locale Settings

locale

This command shows the current locale environment.

Why LANG=C Matters in Scripts

LANG=C forces a simple predictable locale.

Example:

LANG=C sort file.txt

Why scripts care:

  • output becomes more predictable
  • parsing text is easier when translated messages are not changing

This is one of the most practical LPIC ideas in this topic.

Character Encodings

ASCII

Very limited older character set.

UTF-8

Modern common encoding for Unicode text.

ISO-8859

Older family of encodings you may still see in legacy contexts.

Simple idea:

  • UTF-8 is the modern normal case
  • older encodings still matter when dealing with legacy data

iconv

iconv converts text from one encoding to another.

Example:

iconv -f ISO-8859-1 -t UTF-8 old.txt > new.txt

You do not need deep encoding theory here. You do need to know why text can look broken when encoding assumptions are wrong.

Timezone Settings

Common files and paths to recognize:

/etc/timezone
/etc/localtime
/usr/share/zoneinfo/

Helpful tools:

timedatectl
tzselect
date

Show current time settings

timedatectl

Choose a timezone interactively

tzselect

Environment Variable TZ

TZ can set timezone behavior for a process or shell session.

Example:

TZ=UTC date

This is useful for testing or scripting.

Practice Step by Step

1) Inspect the current locale
  1. Run: locale
  2. Look at: LANG, LC_TIME, LC_MESSAGES, and LC_ALL
2) Force a predictable script locale
  1. Run: LANG=C date
  2. Read it as: run this command with a simple predictable locale.
3) Check timezone configuration
  1. Run: timedatectl
  2. Notice the current local time, timezone, and clock status.

Cheat Sheet

  • LANG = default locale
  • LC_* = category-specific locale settings
  • LC_ALL = strongest locale override
  • locale = show locale environment
  • LANG=C = simple predictable locale, useful in scripts
  • UTF-8 = modern common Unicode encoding
  • ASCII, ISO-8859 = older encoding families to recognize
  • iconv = convert text encodings
  • /etc/localtime, /usr/share/zoneinfo/ = timezone-related paths
  • timedatectl, tzselect, date = timezone/time tools
  • TZ = per-process timezone override
🎯

Test Your Knowledge

Complete the quiz to assess your understanding of this course's concepts.