Managing Time and Localization
1. Viewing Current Time
| Command | Description | Example Output |
|---|---|---|
| date | Displays current date and time in default format | Wed Apr 5 14:30:45 EDT 2024 |
| date +%T | Displays current time in HH:MM:SS format | 14:30:45 |
| date +%D | Displays current date in MM/DD/YY format | 04/05/24 |
| timedatectl | Shows system time and timezone settings | Local time: Wed 2024-04-05 14:30:45 EDT |
2. Setting System Time
| Command | Description | Usage |
|---|---|---|
| timedatectl | View and change system time and date settings | timedatectl status |
| date | Display or set the system date and time | date -s "2026-04-05 14:30:00" |
| hwclock | Access the hardware clock (RTC) | hwclock --set --date="2026-04-05 14:30:00" |
Example: Setting System Time with timedatectl
timedatectl set-time "2026-04-05 14:30:00"
timedatectl set-timezone "America/New_York"
Note: Ensure the system has proper NTP (Network Time Protocol) synchronization for accurate timekeeping.
3. Configuring Time Zone
| Command | Description | Example |
|---|---|---|
| timedatectl | View and change system time and timezone settings | timedatectl status |
| timedatectl set-timezone | Set the system timezone | timedatectl set-timezone America/New_York |
| timedatectl list-timezones | List all available timezones | timedatectl list-timezones | grep -i "new york" |
Note: The
timedatectl command is part of systemd and is the preferred method for managing time and date on modern Linux distributions.
4. Synchronizing Time with NTP
| Command | Description | Notes |
|---|---|---|
| timedatectl | timedatectl status |
Shows current time, timezone, and NTP synchronization status |
| timedatectl | timedatectl set-ntp true |
Enables automatic NTP synchronization |
| timedatectl | timedatectl set-timezone America/New_York |
Sets the system timezone |
Example: Check NTP Status
$ timedatectl status
Local time: Mon 2026-04-05 14:30:45 EDT
Universal time: Mon 2026-04-05 18:30:45 UTC
RTC time: Mon 2026-04-05 18:30:45
Time zone: America/New_York (EDT, +0400)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
Note: NTP synchronization is managed by
systemd-timesyncd on most modern Linux distributions.Warning: Disabling NTP can cause time drift and affect services that depend on accurate timestamps.
5. Viewing NTP Status
| Command | Description | Notes |
|---|---|---|
| timedatectl status | Displays current system time, timezone, NTP synchronization status, and RTC configuration. | Shows if NTP is enabled and the source of time synchronization. |
| timedatectl list-timezones | Lists all available timezones on the system. | Useful for setting or verifying timezone configuration. |
| timedatectl show | Shows detailed system time and date settings. | Includes NTP server, RTC settings, and timezone details. |
Example: Check NTP synchronization status
$ timedatectl status
Local time: Mon 2026-04-05 14:30:45 EDT
Universal time: Mon 2026-04-05 18:30:45 UTC
RTC time: Mon 2026-04-05 18:30:45
Time zone: America/New_York (EDT, +0400)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: yes
Note: The
NTP synchronized: yes line indicates that the system is receiving time updates from an NTP server.6. Configuring Hardware Clock
| Command | Description | Notes |
|---|---|---|
| timedatectl set-ntp | Enable NTP synchronization | Requires root privileges |
| timedatectl status | Display current date/time and timezone info | Shows whether NTP is active |
| hwclock --show | Read hardware clock (RTC) | Displays current hardware time |
| hwclock --set --date="2026-04-05 14:30:00" | Set hardware clock to specific time | Requires root privileges |
| hwclock --systohc | Synchronize hardware clock with system time | Updates RTC from system clock |
| hwclock --hctosys | Synchronize system time with hardware clock | Updates system clock from RTC |
Example: Setting Hardware Clock
# Set hardware clock to current system time
sudo hwclock --systohc
# Read current hardware clock
hwclock --show
Note: On systems using systemd,
timedatectl is preferred for managing time and timezone settings.7. Setting System Locale
| Locale Variable | Value Format | Description |
|---|---|---|
| LANG | en_US.UTF-8 |
Primary locale setting affecting most programs |
| LC_ALL | en_US.UTF-8 |
Overrides all other LC_* variables |
| LC_TIME | en_GB.UTF-8 |
Controls date and time formatting |
| LC_MESSAGES | fr_FR.UTF-8 |
Affects message language in programs |
Example: Permanently Setting Locale in /etc/default/locale
# /etc/default/locale
LANG=en_US.UTF-8
LC_TIME=de_DE.UTF-8
Note: Ensure the desired locale is generated in
/etc/locale.gen and run locale-gen to make it available.
Warning: Setting
LC_ALL overrides all other locale settings and may cause unexpected behavior in some applications.
8. Viewing Available Locales
| Locale Identifier | Description | Language | Country/Region |
|---|---|---|---|
| en_US | English (United States) | English | United States |
| fr_FR | French (France) | French | France |
| de_DE | German (Germany) | German | Germany |
| es_ES | Spanish (Spain) | Spanish | Spain |
| ja_JP | Japanese (Japan) | Japanese | Japan |
| ko_KR | Korean (South Korea) | Korean | South Korea |
| zh_CN | Chinese (Simplified, China) | Chinese | China |
| ru_RU | Russian (Russia) | Russian | Russia |
| pt_BR | Portuguese (Brazil) | Portuguese | Brazil |
| ar_SA | Arabic (Saudi Arabia) | Arabic | Saudi Arabia |
9. Generating Locales
| Locale Identifier | Description | Example |
|---|---|---|
| en_US | English (United States) | en_US.UTF-8 |
| fr_FR | French (France) | fr_FR.UTF-8 |
| de_DE | German (Germany) | de_DE.UTF-8 |
| ja_JP | Japanese (Japan) | ja_JP.UTF-8 |
| zh_CN | Chinese (Simplified, China) | zh_CN.UTF-8 |
Note: On Debian/Ubuntu systems, use
locale-gen. On Red Hat/CentOS systems, use localedef.
10. Configuring Keyboard Layout
| Property | Value | Description |
|---|---|---|
| keyboard.layout | us |
Primary keyboard layout (e.g., us, gb, de) |
| keyboard.variant | altgr-intl |
Variant of the layout (e.g., altgr-intl, colemak) |
| keyboard.model | pc105 |
Keyboard model (e.g., pc105, mac) |
Note: Changes made with
localectl persist across reboots, while setxkbmap is session-specific.