Linux Timezone Management
1. Understanding /usr/share/zoneinfo
​
The /usr/share/zoneinfo
directory, also known as the "tz database" or "tzdata", is a crucial component of Linux systems that contains timezone information files.
Structure​
/usr/share/zoneinfo/
├── Africa/
├── America/
├── Asia/
├── Europe/
└── ...
Purpose​
- Contains timezone rules and data files
- Manages daylight saving transitions
- Stores historical timezone changes
- Provides UTC offset information
2. Using tzselect - Interactive Timezone Selector​
Starting tzselect​
/usr/bin/tzselect
Interactive Process​
- Select continent/region:
1) Africa
2) Americas
3) Antarctica
4) Asia
...
- Select country:
# For Asia/Jerusalem:
4) Asia
5) Israel
- Confirm selection:
The following information has been given = Israel
Therefore TZ='Asia/Jerusalem' will be used.
Selected time is now: Fri Jun 27 09:41:46 IDT 2025.
Universal Time is now: Fri Jun 27 06:41:46 UTC 2025.
3. User-Specific Timezone Configuration (.profile)​
Editing .profile​
nano ~/.profile
Add Timezone Configuration​
# Add to ~/.profile
TZ='Asia/Jerusalem'; export TZ
.profile TZ Characteristics​
- User-specific environment setting
- Does not affect system-wide timezone
- Applied only to user's shell sessions
- Changes are temporary
- Requires shell restart or source command
Apply Changes​
source ~/.profile
4. System-Wide Timezone Configuration (timedatectl)​
Understanding timedatectl Output​
timedatectl
Local time: Fri 2025-06-27 09:59:57 IDT
Universal time: Fri 2025-06-27 06:59:57 UTC
RTC time: Fri 2025-06-27 06:59:58
Time zone: Asia/Jerusalem (IDT, +0300)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
Components Explained​
- Local time: Current time in selected timezone
- Universal time: UTC time
- RTC time: Hardware clock time
- Time zone: Current system timezone
- NTP service: Network Time Protocol status
Setting System Timezone​
Method 1: Using timedatectl (Recommended)​
sudo timedatectl set-timezone Asia/Jerusalem
Method 2: Manual Configuration​
# Update localtime symlink
sudo ln -sf /usr/share/zoneinfo/Asia/Jerusalem /etc/localtime
# Update timezone file
echo "Asia/Jerusalem" | sudo tee /etc/timezone
Verify Changes​
# Check current settings
timedatectl
# Verify timezone file
cat /etc/timezone
# Check localtime symlink
ls -l /etc/localtime
Best Practices​
-
System-wide Changes
- Use
timedatectl
for permanent system changes - Affects all users and services
- Persists across reboots
- Use
-
User-specific Changes
- Use
.profile
for personal timezone preferences - Only affects user sessions
- Useful for development environments
- Use
-
Docker Containers
- Use timezone volume mounts
- Set TZ environment variable
volumes:
- /usr/share/zoneinfo/Asia/Jerusalem:/etc/timezone:ro
- /usr/share/zoneinfo/Asia/Jerusalem:/etc/localtime:ro
environment:
- TZ=Asia/Jerusalem -
Troubleshooting
- Check file permissions
- Verify timezone file exists
- Ensure NTP service is running
- Check for error messages in system logs