Linux Change Timezone, Date and Time Commands

By Raju

May 17, 2018


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. Let's explore Linux change timezone, Linux date command and Linux time commands with easy examples.  

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.

# date
Mon 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/localtime
lrwxrwxrwx 1 root root 34 May 14 11:25 /etc/localtime -> ../usr/share/zoneinfo/Asia/Kolkata

Linux Change Timezone 

The timedatectl command is a new command utility for CentOS 7/RHEL , It's also a replacement for old traditional Linux 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: yes
NTP 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/Dhaka
Asia/Dili
Asia/Dubai
Asia/Hong_Kong
Asia/Jakarta
Asia/Jayapura
Asia/Kabul
Asia/Kamchatka
Asia/Karachi
Asia/Kathmandu
Asia/Khandyga
Asia/Kolkata
Asia/Krasnoyarsk
Asia/Kuala_Lumpur
Asia/Kuching
Asia/Kuwait
Asia/Macau

To set Linux 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, linux time with simple commands. You can learn more from timedatectl command man pages. 

FastWebHost India offers VPS and cheap dedicated server hosting for advanced users and businesses. 

Feel free to give feedback or leave a comment.

Leave a Reply

Your email address will not be published. Required fields are marked

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Create a website in 3 simple steps

Choose a website template, add features, then customise! - Free Online Website builder.