Configuring Timezone and Locale Settings on a Linux Server

Server timezone and locale misconfiguration causes subtle bugs — log timestamps that don’t match reality, date parsing that breaks for specific number formats — worth getting right at provisioning time rather than discovering the hard way.

# Check and set the system timezone
timedatectl status
sudo timedatectl set-timezone Europe/Berlin

# List available timezones if you're not sure of the exact name
timedatectl list-timezones | grep Berlin

# Check and generate locales
locale -a
sudo locale-gen en_US.UTF-8
sudo update-locale LANG=en_US.UTF-8

Servers Should Almost Always Run UTC

Setting a server’s system time to UTC (rather than a local timezone) avoids an entire category of bugs around daylight saving time transitions and makes correlating logs across servers in different physical regions trivial — timezone conversion for display purposes should happen at the application layer, not by changing the underlying system clock.

Locale Affects More Than You’d Expect

Locale settings influence date formatting, number formatting (decimal comma vs period), sort order, and even which characters some command-line tools treat as valid — a mismatched locale is a surprisingly common, hard-to-immediately-recognize cause of scripts behaving differently across servers that otherwise look identically configured.