Keeping the correct date and time on your Linux system is crucial for logging, security, and network synchronization. Whether you need to manually adjust the Linux set date, synchronize time with an online server, or configure time zone settings, Linux offers multiple ways to do so. This Linux set date guide will walk you through different methods for setting the date and time on Linux, ensuring accuracy and proper system functionality.

 

Understanding Date and Time Management in Linux

Linux systems use a combination of hardware and system clocks. The hardware clock (RTC - Real-Time Clock) keeps track of time even when the system is powered off, while the system clock (software clock) is maintained by the operating system after booting.

To manage time, Linux uses tools such as:

  • date – Displays and sets the system date and time manually.

  • timedatectl – Controls the system time and synchronizes it with NTP (Network Time Protocol).

  • hwclock – Manages the hardware clock settings.

 

Understanding the Difference Between System Clock and Hardware Clock

Linux has two types of clocks:

  • System Clock (Software Clock): Maintained by the Linux kernel after the system boots up. It does not persist when the system is powered off.

  • Hardware Clock (RTC - Real-Time Clock): A battery-powered clock that keeps running even when the system is off.

When Linux boots, it reads the hardware clock to set the system clock. If the time is incorrect, you might need to adjust both clocks separately.

To check both clocks, run:

hwclock --show

date

To sync the system clock with the hardware clock, use:

sudo hwclock --systohc

To set the hardware clock from the system clock:

sudo hwclock --set --date "2025-03-25 14:45:00"

To ensure the hardware clock remains accurate, set it to UTC instead of local time:

sudo hwclock --systohc --utc

 

Checking the Current Linux Set Date and Time

Before making changes, check your system’s current time using:

date

This will return an output like:

Thu Mar 25 14:30:15 UTC 2025

To view more details for set date Linux, including the hardware clock, use:

timedatectl status

This command will show:

            Local time: Thu 2025-03-25 14:30:15 UTC

          Universal time: Thu 2025-03-25 14:30:15 UTC

           RTC time: Thu 2025-03-25 14:30:15

          Time zone: UTC (UTC, +0000)

 

 

How to Manually Change Linux Set Date and Time

Using the date Command

To manually set the date and time, use:

sudo date MMDDhhmmYYYY

 

For example, to set the date to March 25, 2025, at 14:45:

sudo date 032514452025

After setting the time, confirm the change with:

Date

 

Setting Date and Time Permanently

To ensure changes persist after reboot, update the hardware clock:

sudo hwclock --systohc

This syncs the system time to the hardware clock.

 

How to Change the Linux Set Time Zone

To set or change the time zone, follow these steps:

  1. List available time zones:

timedatectl list-timezones

  1. Set the preferred time zone, for example, to New York:

sudo timedatectl set-timezone America/New_York

  1. Verify the change:

Timedatectl

 

Linux Set Date from Internet Time Servers

Keeping your system’s time synchronized is important for security and consistency. Most modern Linux distributions use NTP (Network Time Protocol) for automatic time synchronization.

 

Enable Time Synchronization

To enable NTP time synchronization, run:

sudo timedatectl set-ntp on

Check if it is active:

timedatectl

If NTP is not installed, install it using:

  • Ubuntu/Debian:

sudo apt install ntp

  • CentOS/Rocky Linux:

sudo yum install ntp

To manually sync the time:

sudo ntpdate pool.ntp.org

 

Setting Linux Set Date and Time in Different Linux Distributions

Arch Linux

To enable automatic time synchronization:

sudo systemctl enable systemd-timesyncd

sudo systemctl start systemd-timesyncd

To manually set the time:

sudo date 032514452025

 

Rocky Linux

For setting time manually:

sudo timedatectl set-time "2025-03-25 14:45:00"

To synchronize with an NTP server:

sudo systemctl enable --now chronyd

 

Oracle Linux

To manually set the date:

sudo date --set="2025-03-25 14:45:00"

For automatic time updates:

sudo yum install ntp

sudo systemctl enable ntpd –now

 

Kali Linux

Setting date and time manually:

sudo date 032514452025

To sync time from the internet:

sudo timedatectl set-ntp true

 

Configuring Date Format in Linux

Linux allows you to display the date in different formats. Some common options include:

  • DD-MON-YYYY format:

date +"%d-%b-%Y"

  • UNIX timestamp (seconds since Jan 1, 1970):

date +%s

  • Full date and time in ISO 8601 format:

date +"%Y-%m-%dT%H:%M:%S%z"

 

How to Use Chrony for Time Synchronization in Linux

While ntpd is the traditional method for syncing time with an NTP server, many modern Linux distributions recommend using Chrony, which is faster and better suited for systems that frequently go offline.

To install Chrony:

  • Ubuntu/Debian:

sudo apt install chrony

  • CentOS/Rocky Linux:

sudo yum install chrony

Enable and start Chrony:

sudo systemctl enable --now chronyd

To manually sync time using Chrony:

sudo chronyc tracking

sudo chronyc sources -v

To force synchronization immediately:

sudo chronyc makestep

Chrony is particularly useful for virtual machines, embedded systems, and laptops, where the clock may drift significantly due to suspensions or reboots.

 

How to Set the Date and Time Using GUI in Linux

For users who prefer a graphical interface for Linux date set, most Linux desktop environments provide an easy way to adjust the date and time.

GNOME (Ubuntu, Fedora, Debian)

  1. Open Settings.

  2. Navigate to Date & Time.

  3. Toggle Automatic Date & Time if you want to use an internet time server.

  4. To set the time manually, disable automatic sync and enter the desired date and time.

KDE Plasma (Kubuntu, OpenSUSE, Arch Linux)

  1. Open System Settings.

  2. Go to Regional Settings > Date & Time.

  3. Click Set Date and Time and enter the correct values.

For systems that do not allow GUI changes due to administrative restrictions, you can use the timedatectl command for Linux set date clock instead.

 

 

Troubleshooting Time Synchronization Issues in Linux

If your Linux system fails to update its time correctly, try these troubleshooting steps:

1. Check If NTP Synchronization Is Enabled

Run:

timedatectl status

If NTP synchronized: no, enable it:

sudo timedatectl set-ntp on

2. Restart the NTP or Chrony Service

For ntpd:

sudo systemctl restart ntpd

For Chrony:

sudo systemctl restart chronyd

3. Manually Force Time Sync

If automatic sync fails, manually sync time with an NTP server:

sudo ntpdate pool.ntp.org

4. Verify System Logs for Errors

Check logs to identify time synchronization issues:

journalctl -xe | grep -i "time"

 

Final Thoughts

Managing date and time in Linux is essential for maintaining system integrity, security, and performance. Whether you're setting the time manually, synchronizing it with an NTP server, or configuring time zones, Linux offers multiple methods to ensure your system's clock is always accurate.

For everyday users, enabling automatic synchronization with timedatectl or Chrony is the simplest and most reliable option. However, advanced users can fine-tune their settings using commands like hwclock, date, and ntpdate.

By following this guide, you can ensure that your Linux system's date and time settings remain correct and consistent, preventing issues with logs, authentication, and network communication. You can also check out our Linux VPS hosting options if you want to host your own Linux VPS.

 

People also read: