Home > Linux > Changing date and timezone in Linux

Changing date and timezone in Linux

I am on CentOS 6.5

You can use the date command to see the current time and timezone

[naveen@localhost ~]$ date
Thu Sep 18 13:54:34 MDT 2014

To see the hardware clock

hwclock
Thu 18 Sep 2014 01:55:42 PM MDT -0.114261 seconds

To change the date

sudo date --set="Sep 18 2014 13:55:00"

To change your timezone, we need to replace the file /etc/localtime

The available timezones are located in /usr/share/zoneinfo/

All you have to do is copy the required file from there to /etc/localtime to change your timezone

First make a backup of your existing /etc/localtime file

sudo mv /etc/localtime /etc/localtime.bkp
sudo cp /usr/share/zoneinfo/UTC /etc/localtime

Now when i execute the command i get the new date in UTC

[naveen@localhost ~]$ date
Thu Sep 18 19:57:29 UTC 2014

 

Categories: Linux Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: