Management Portal

How to Change Timezone on CentOS Server

How to Change Timezone on CentOS Server

How to Change Timezone on CentOS Server

QuadraNet proudly offers CentOS Server as an operating system option for our Dedicated Servers and InfraCloud solutions. In this tutorial, we will be covering how to change the timezone on any RHEL/CentOS based server (5/6/7).

To begin, we first verify the existing timezone on the server. You can do this by running the following command in a SSH prompt. In the example displayed below, we see that our server is currently in the UTC timezone.

[root@ ~]# date
Mon Dec 12 20:25:47 UTC 2016

Changing the TimeZone in CentOS 5/6

Changing the timezone on a system running on CentOS version 5 or 6 is quite simple. We simply link /etc/localtime file with the correct timezone configuration file.

Please note that all timezone setting files are located under the /usr/share/zoneinfo/ directory.

In the example below, we will set our server to the Los Angeles timezone (PST). This is identified as America/Los_Angeles:

[root@~]# mv /etc/localtime /root/localtime.bak
[root@~]# ln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime

We verify that the timezone was set successfully by running the “date” command again:

[root@~]# date
Mon Dec 12 12:28:25 PST 2016

Changing the TimeZone in CentOS 7

Changing the timezone on a system running on CentOS version 7 is slightly different than versions 5 or 6. In CentOS 7, we use the timedatectl command to change the timezone of the system.

To list the timezone options, use the command as demonstrated below:

[root@~]# timedatectl list-timezones
..

We can use the following command to change the timezone to the desired zone. In the example below, we will change the timezone to the Los Angeles timezone (PST). This is identified as America/Los_Angeles:

[root@~]# timedatectl set-timezone America/Los_Angeles

We verify that the timezone was set successfully by running the “date” command:

[root@~]# date
Mon Dec 12 12:37:26 PST 2016

As always, if you need any assistance or have any questions about our hosting services, please feel free to contact us.