• Home
  • Disclaimer
  • Contact
  • Archives
  • About
  • Subscribe
  • Support
  • Advertise

Kernel Talks

Unix, Linux, & Cloud!

  • How-to guides
    • Howto
    • Disk management
    • Configurations
    • Troubleshooting
  • OS
    • HPUX
    • Linux
  • Miscellaneous
    • Software & Tools
    • Cloud Services
    • System services
    • Virtualization
  • Certification Preparations
    • AWS Certified Solutions Architect – Associate
    • AWS Certified Solutions Architect – Professional
    • AWS Certified SysOps Administrator – Associate
    • AWS Certified Cloud Practitioner
    • Certified Kubernetes Administrator
    • Hashicorp Certified Terraform Associate
    • Oracle Cloud Infrastructure Foundations 2020 – Associate
  • Tips & Tricks
  • Linux commands
You are here: Home / Commands

Date & time management in Linux using timedatectl command

Published: November 15, 2017 | Modified: June 25, 2020



Learn timezone management using timedatectl command. An article explaining different uses of timedatectl command along with examples.

Learn timedatectl command

In our previous article, we have seen how to change the timezone of the Linux server using files or variables in the system. Few of our readers pushed timedatectl command to achieve this task easily. So I thought of writing a separate article on timedatectl command explaining all its usage.

In this article, we will see how to display server time details, view, list, and change the timezone of the server using timedatectl command. If you want to use date or time in a shell script or as a variable, we explained here how to format the date and time to use it as variable or in scripting.

timedatectl is Time Date Control command! It used to control the date and time of the server in Linux. To check your current system date and time details, run this command without any switch –

root@kerneltalks # timedatectl
      Local time: Wed 2017-11-15 15:58:33 UTC
  Universal time: Wed 2017-11-15 15:58:33 UTC
        RTC time: Wed 2017-11-15 15:58:32
       Time zone: UTC (UTC, +0000)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

Where,

  • Local time : Your system’s local date and time
  • Universal time : Current UTC time
  • RTC time : Current Real-time clock time
  • Time zone : Your system’s current timezone
  • NTP enabled : Is NTP is enabled on system or not
  • NTP synchronized : NTP time synced or not.
  • RTC in local TZ : Is RTC maintaining in configured system TZ? It is recommended to keep it off.
  • DST active : Daylight saving time enabled or not

List and change timezone using timedatectl

timedatectl allow you to change the timezone of the system with a list of available timezones.  To view, a list of available timezones use the command with list-timezones switch.

root@kerneltalks # timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
----- output clipped-----

You will be presented with a list of available timezones in a paged manner. You can use any of thee timezones to set on your local system. To change timezone of your system use set-timezone switch.

root@kerneltalks # timedatectl set-timezone Australia/Sydney

Above command will change server timezone to Australia/Sydney one.


Change date and time using timedatectl

Most of the servers are configured with NTP these days. But if not and/or if you want to change the date and time manually then you can use set-time switch. Time should be supplied with YYYY-MM-DD HH:MM:SS

root@kerneltalks # timedatectl set-time "2018-01-01 12:12:12"

If NTP is configured then you might see an error Failed to set time: Automatic time synchronization is enabled when attempting to change system time manually.


Enable/Disable RTC and NTP using timedatectl

You can enable or disable RTC (Real Time Clock) and NTP using timedatectl. For RTC use set-local-rtc and for NTP use set-ntp switch. Both arguments accepts 1 (to enable) and 0 (to disable) as values.

root@kerneltalks # timedatectl set-ntp 0
root@kerneltalks # timedatectl set-local-rtc 0

Please note that enabling NTP here does not take you through NTP configuration steps. That has to be done separately. This only controls if the system should sync time using configured NTP or not.


Manage date and time of other machine

You can use timedatectl command to manage the date and time of local containers or remote machines. To manage the time of local container use -M switch whereas to connect to the remote host and manage its time use -H switch.

-M switch takes argument as --host=ip/hostname. -H switch takes argument as --machine=container_name.

That’s all switches which are mainly useful in day-to-day operations. There are a few more that can be referred from its man page.

⇠ Previous article
How to troubleshoot RPC: Port mapper failure – Timed out error
Next article ⇢
xfs file system commands with examples

Related stuff:

  • xfs file system commands with examples
  • sar command (Part III) : Disk, Network reporting
  • How to create tar file in Linux or Unix
  • 5 different examples to send email through Linux terminal
  • 12 useful zypper command examples
  • Finger command in Linux
  • How to zip, unzip files and directories in Linux / Unix
  • How to save top command output in file
  • 12 examples of ls command in Linux for daily use
  • How to replay Linux session recorded by the script command
  • How to change process priority in Linux or Unix
  • Learn Rsync command with examples

Filed Under: Commands Tagged With: ntp disable using timedatectl, rtc enable using timedatectl, timedatectl command, timezone using timedatectl

If you like my tutorials and if they helped you in any way, then

  • Consider buying me a cup of coffee via paypal!
  • Subscribe to our newsletter here!
  • Like KernelTalks Facebook page.
  • Follow us on Twitter.
  • Add our RSS feed to your feed reader.

Share Your Comments & Feedback: Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get fresh content from KernelTalks

  • Email
  • Facebook
  • RSS
  • Twitter

Get Linux & Unix stuff right into your mailbox. Subscribe now!

* indicates required

This work is licensed under a CC-BY-NC license · Privacy Policy
© Copyright 2016-2023 KernelTalks · All Rights Reserved.
The content is copyrighted to Shrikant Lavhate & can not be reproduced either online or offline without prior permission.