Locale, Time & System Configuration
Module 7 · System Configuration & Software

Locale, Time & System Configuration

timedatectl, localectl, hwclock, and how Linux handles timezones, character encoding, and regional settings.

Localization

Localization is the process of adapting system components — language, date format, currency, keyboard layout — for a specific region or audience. The /usr/share/zoneinfo/ directory is the container for every regional timezone definition the system can be configured to use.

TaskCommand
View or set system date/time (the modern, systemd-native tool)timedatectl
Show current date/time/timezone statustimedatectl status
Set the timezonetimedatectl set-timezone America/Los_Angeles
Set the system clock manuallytimedatectl set-time "2026-08-25 09:00:00"
Print the date in a specific formatdate "+%Y-%m-%d %H:%M:%S"
Common date format codes%Y year, %m month, %d day, %H:%M:%S time
View the configured timezone directly (Debian-family systems)cat /etc/timezone

The hardware clock: the motherboard keeps its own battery-backed clock (RTC) independent of the OS, so time survives a power-off. Sync between the two with hwclock:

TaskCommand
View the hardware clockhwclock (or hwclock --show)
Set the hardware clock from the system clockhwclock --systohc
Set the system clock from the hardware clockhwclock --hctosys
⚠️ Common Pitfall: Two Clocks, Two Sources of Truth

date and timedatectl operate on the OS’s software clock. hwclock operates on the motherboard’s separate hardware clock. These can drift out of sync with each other — a system with the wrong time after a reboot, despite date showing correctly before shutdown, is a classic sign the two clocks disagree and need an explicit hwclock --systohc.


Locale and Keyboard Layout

localectl manages the system’s language/locale and keyboard layout settings:

TaskCommand
Show current locale/keyboard settingslocalectl status
Set the system-wide language localelocalectl set-locale LANG=en_US.UTF-8
Set the keyboard layoutlocalectl set-keymap us

Character Encoding

Encoding converts text into bytes for storage or transmission; decoding converts those bytes back into readable text. Nearly every modern Linux system defaults to UTF-8 — a variable-width encoding that can represent virtually any character from any language while staying backward-compatible with plain ASCII for the first 128 characters.

⚠️ Common Pitfall: Encoding Mismatches Cause 'Mojibake'

Garbled text (question marks, boxes, or nonsense characters where accented letters or non-Latin scripts should be) almost always means a file was written in one encoding and read assuming another. Check a file’s actual encoding with file -i filename, and check the shell’s active locale with locale before assuming the file itself is corrupted.


🧠 Knowledge Check

1. A server's date command shows the correct time before a reboot, but after rebooting the clock is wrong. What should you check?

2. Which command is the modern, systemd-native way to view and set the system date, time, and timezone?

3. What encoding does the vast majority of modern Linux systems default to?


What’s Next

Lesson 2 covers the graphical side of the system: display servers, desktop environments, and how to reach a GUI remotely.