• 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

CentOS / RHEL 7 : How to set date, time / NTP and timezone using timedatectl

by admin

RHEL 7 offers another utility to configure and display date and time information, timedatectl. This utility is part of the systemd system and service manager. With the timedatectl command you can :

  • Change the current date and time
  • Set the time zone
  • Configure NTP

If you run timedatectl without any options, you would get an output similar to below :

# timedatectl 
      Local time: Sun 2017-09-24 13:16:39 IST
  Universal time: Sun 2017-09-24 07:46:39 UTC
        RTC time: Sun 2017-09-24 07:46:39
       Time zone: Asia/Kolkata (IST, +0530)
     NTP enabled: no
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

The above output shows – local time, universal time, RTC time, time zone, NTP configuration and Daylight Savings Time (DST)

Change the current date and time

Use the set-time argument to change the current date and the current time.

1. To change the date, use the following syntax:

# timedatectl set-time [YYYY-MM-DD]

2. To change the current time, use the following syntax. Enter the hour by using a 24-hour clock.

# timedatectl set-time [HH:MM:SS]

3. To configure your system to maintain the clock in the local time, use the following command:

# timedatectl set-local-rtc yes

4. To configure your system to use UTC, use the following command:

# timedatectl set-local-rtc no

Change Time Zone

Use the following command to list all available time zones:

# timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
.....

Use the set-timezone argument to change the time zone. The following example changes the time zone to Asia/Kolkata:

# timedatectl set-timezone Asia/Kolkata

Configuring NTP

Use the set-ntp argument to enable or disable automatic synchronization of your system clock with a remote server over the Network Time Protocol (NTP). Use the following command to enable this feature:

# timedatectl set-ntp yes

Use the following command to disable this automatic synchronization over NTP:

# timedatectl set-ntp no

Filed Under: CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. crontab error : “You (user) are not allowed to access to (crontab) because of pam configuration.”
  2. How To Configure sssd To Work With Multiple Active Directory Domains in Different Forests (CentOS/RHEL)
  3. How to use ‘yum’ to connect ULN on CentOS/RHEL/OEL 6
  4. How to use ldconfig Command in Linux
  5. “Leap status Not synchronised” – On running ‘chronyc tracking’
  6. lsscsi Command Examples in Linux
  7. How To Change Timezone for Oracle Grid Infrastructure
  8. How to Enable Verbose Logging for VSFTPD
  9. CentOS / RHEL 7 : How to create an Network Bonding (NIC teaming) using nmcli
  10. Configuring sudo to Enable Commands for Non-Root Users in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • vgextend Command Examples in Linux
  • setpci command – configure PCI device
  • db_load command – generate db database
  • bsdtar command – Read and write tape archive files

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright