Linux Change Timezone, Date and Time Commands

When you buy CentOS/RHEL Linux VPS or dedicated server from any hosting provider the server OS will have default timezone settings set to server location. It means if you buy server in USA, your server will have USA Timezones.

You can easily change Linux date, time and timezone suitable to your working timezone.

Linux Date Command

To see your present server date, time and time zone use below command.

# dateMon May 14 11:51:12 IST 2018

Linux Timezone Config Files

CentOS stores all timezone configuration files in folder /var/share/zoneinfo/

The timezone config folder contains all timezone with their respective name. For Example: India timezone file will be located in /var/share/zoneinfo/Asia/Kolkata

/etc/localtime - This is a file which links to correct timezone file in /var/share/zoneinfo/

ls -l /etc/localtimelrwxrwxrwx 1 root root 34 May 14 11:25 /etc/localtime -> ../usr/share/zoneinfo/Asia/Kolkata

Change Timezone in Linux

The timedatectl command is a new command utility for CentOS 7/RHEL , It's also a replacement for old traditional date command. The command output will be something like this.

# timedatectl Local time: Mon 2018-05-14 12:06:11 IST Universal time: Mon 2018-05-14 06:36:11 UTC RTC time: Mon 2018-05-14 06:36:11 Time zone: Asia/Kolkata (IST, +0530) NTP enabled: yesNTP synchronized: yes RTC in local TZ: no DST active: n/a

You can see  date, time and timezone information clearly with timedatectl

Let's change server timezone to another. First, we need to figure out target timezone name. The below command will show all the available timezones on the server.

# timedatectl list-timezones | less

To see all Asian countries timezone use below command.

# timedatectl list-timezones | grep Asia    

Asia/DhakaAsia/DiliAsia/DubaiAsia/Hong_KongAsia/JakartaAsia/JayapuraAsia/KabulAsia/KamchatkaAsia/KarachiAsia/KathmanduAsia/KhandygaAsia/KolkataAsia/KrasnoyarskAsia/Kuala_LumpurAsia/KuchingAsia/KuwaitAsia/Macau

To set timezone to Singapore time, the syntax and actual command will look like this

# timedatectl set-timezone time_zone    - Syntax

# datetimectl set-timezone Asia/Singapore

Summary

We hope you learned how to change Linux/CentOS/RHEL timezones with simple commands. You can learn more from timedatectl command man pages.

Feel free to give feedback or leave a comment.