• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

timedatectl Command Examples in Linux

by admin

A new command that was introduced in systemd-based distributions that enables you to manage many aspects of time is timedatectl. When used without any arguments, this command shows detailed information about the current time and date. It also displays the time zone your system is in, in addition to information about the use of NTP network time and information about the use of DST.

# timedatectl
                Local time: Mon 2019-06-10 08:27:57 EDT
            Universal time: Mon 2019-06-10 12:27:57 UTC
                  RTC time: Mon 2019-06-10 12:27:57
                 Time zone: America/New_York (EDT, -0400)
 System clock synchronized: yes
               NTP service: active
           RTC in local TZ: no

Most Common Options with timedatectl Command

Command Explanation
status Shows the current time settings
set-time TIME Sets the current time
set-timezone ZONE Sets the current time zone
list-timezone Shows a list of all time zones
set-local-rtc [0|1] Controls whether the RTC (the real-time clock, normally referred to as the hardware clock) is in local time
set-ntp [0|1] Controls whether NTP is enabled

timedatectl Command Examples

1. Check the current system clock time:

# timedatectl

2. Set the local time of the system clock directly:

# timedatectl set-time "yyyy-MM-dd hh:mm:ss"

3. List available timezones:

# timedatectl list-timezones

4. Set the system timezone:

# timedatectl set-timezone timezone

5. Enable Network Time Protocol (NTP) synchronization:

# timedatectl set-ntp on

6. We can change the date using the following command:

# timedatectl set-time 2014-07-19

7. The time can be set using the same option with time as the argument, shown as follows:

# timedatectl set-time 23:02:23

8. NTP time synchronization can be enabled and disabled with the following command; though, it uses the news system service manager to enable and disable the time service:

# timedatectl set-ntp yes

9. If you have found the right time zone, write it down and use it in the next command; for example, if you are located in Germany and are near the city of Berlin, use the following command:

# timedatectl set-timezone Europe/Berlin

10. Use timedatectl again to check if your local time is correct now:

# timedatectl | grep "Local time"

Summary

The newer systemd-based distributions include a simple command to display and manage time and date settings on the host system: timedatectl. This really is a godsend to us as administrators; even if we only use the command to display the output, this one command will display the time, timezone, and NTP settings.

Filed Under: Linux

Some more articles you might also be interested in …

  1. Understanding /etc/xinetd.conf file in Linux
  2. /etc/rsyslog.conf – Setup a Filter to Discard or Redirect Messages
  3. postfix: command not found
  4. gprof: command not found
  5. CentOS / RHEL : How to Disable / Enable direct root and non-root user ssh login
  6. keyctl: command not found
  7. How to create and mount Btrfs file system (explained with examples)
  8. conntrack: command not found
  9. How to disable swap in Linux
  10. pacman –sync Command Examples

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright