Linux Time Synchronization - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
⏰ Linux Time Synchronization Guide
Complete beginner-friendly guide to time synchronization on Linux, covering Arch Linux, CachyOS, and other distributions including NTP, systemd-timesyncd, and timezone configuration.
Table of Contents
- Understanding Time Synchronization
- Timezone Configuration
- systemd-timesyncd
- NTP Configuration
- Hardware Clock
- Troubleshooting
Understanding Time Synchronization
What is Time Synchronization?
Time synchronization keeps system time accurate.
What it does:
- Accurate time: Keeps time correct
- Network sync: Syncs with time servers
- Timezone: Handles timezones
- Consistency: Consistent time across network
Why it matters:
- Security: Certificates require accurate time
- Logs: Accurate timestamps
- Scheduling: Cron jobs, etc.
- Network: Network protocols need accurate time
Timezone Configuration
Set Timezone
List timezones:
# List available timezones
timedatectl list-timezones
Set timezone:
# Set timezone
sudo timedatectl set-timezone America/New_York
# Or
sudo timedatectl set-timezone Europe/London
Check timezone:
# Check time and timezone
timedatectl
⏱ systemd-timesyncd
Enable timesyncd
Enable service:
# Enable timesyncd
sudo systemctl enable systemd-timesyncd
sudo systemctl start systemd-timesyncd
# Check status
timedatectl status
Configure timesyncd
Edit config:
# Edit config
sudo vim /etc/systemd/timesyncd.conf
Example:
[Time]
NTP=0.arch.pool.ntp.org 1.arch.pool.ntp.org
FallbackNTP=0.pool.ntp.org 1.pool.ntp.org
Restart service:
sudo systemctl restart systemd-timesyncd
NTP Configuration
Install NTP
Install NTP:
# Arch/CachyOS
sudo pacman -S ntp
# Debian/Ubuntu
sudo apt install ntp
# Fedora
sudo dnf install ntp
Enable NTP
Enable service:
# Enable service
sudo systemctl enable ntpd
sudo systemctl start ntpd
# Check status
systemctl status ntpd
Configure NTP
Edit config:
# Edit config
sudo vim /etc/ntp.conf
Add servers:
server 0.arch.pool.ntp.org
server 1.arch.pool.ntp.org
server 2.arch.pool.ntp.org
server 3.arch.pool.ntp.org
Restart:
sudo systemctl restart ntpd
Hardware Clock
Check Hardware Clock
Check clock:
# Check hardware clock
sudo hwclock --show
# Check system clock
date
Sync Hardware Clock
Sync to system:
# Sync hardware clock to system
sudo hwclock --systohc
# Sync system to hardware clock
sudo hwclock --hctosys
Set Hardware Clock
Set clock:
# Set hardware clock
sudo hwclock --set --date "2024-01-15 10:00:00"
Troubleshooting
Time Not Syncing
Check sync status:
# Check timesyncd
timedatectl status
# Check NTP
ntpq -p
Wrong Timezone
Set timezone:
# List timezones
timedatectl list-timezones
# Set timezone
sudo timedatectl set-timezone Your/Timezone
Summary
This guide covered time synchronization for Arch Linux, CachyOS, and other distributions, including timezone configuration, systemd-timesyncd, NTP, and hardware clock.
Next Steps
- Locale and Language - Locale setup
- System Configuration - System setup
- ArchWiki Time: https://wiki.archlinux.org/title/System_time
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.