• 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. How to Create and Mount Btrfs Snapshots
  2. How to disable a specific command for a specific user in Linux
  3. bmon Command Examples in Linux
  4. How to use command line shell functions in Linux
  5. snap Command Examples in Linux
  6. Server Application Getting “connection refused” From Remote Servers [due to firewalld or iptables] – CentOS/RHEL 7
  7. How to Re-Create the Yum Cache and/or Force a Fetch of the Package List of the Enabled Repositories
  8. How to Change Default Port of Apache On RHEL/CentOS 7
  9. Beginners Guide to NFS in CentOS / RHEL
  10. lsblk: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • qtchooser Command Examples in Linux
  • qtchooser: command not found
  • qsub Command Examples in Linux
  • qsub: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright