Set Time Zone on CentOS 7

Checking the Current Timezone

In CentOS and other modern Linux distros, you can use the timedatectl command to display and set the current system’s time and timezone.

timedatectl

The output below shows that the system’s timezone is set to UTC:

Local time: Wed 2019-02-06 22:43:42 UTC
Universal time: Wed 2019-02-06 22:43:42 UTC
RTC time: Wed 2019-02-06 22:43:42
Time zone: Etc/UTC (UTC, +0000)
NTP enabled: no
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a

The system timezone is configured by symlinking /etc/localtime to a binary timezone identifier in the /usr/share/zoneinfo directory. So, another option to check the timezone is to show the path the symlink points to using the ls command:

ls -l /etc/localtime
lrwxrwxrwx. 1 root root 29 Dec 11 09:25 /etc/localtime -> ../usr/share/zoneinfo/Etc/UTC

Changing Timezone in CentOS

Before changing the timezone, you’ll need to find out the long name for the timezone you want to use. The timezone naming convention usually uses a “Region/City” format.

To list all available time zones, you can either list the files in the /usr/share/zoneinfo directory or use the timedatectl command.

timedatectl list-timezones
...
America/Tijuana
America/Toronto
America/Tortola
America/Vancouver
America/Whitehorse
America/Winnipeg
...

Once you identify which time zone is accurate to your location, run the following command as sudo user:

Read more

Share

TimeZone adjust in Linux

 

For Redhat/CentOS/Fedora/SL distribution
Type the redhat-config-date command at the command line to start the time and date properties tool, run:
# redhat-config-date
OR type setup and select time zone configuration. This tool is recommended for remote ssh text based sessions.
# setup
Select timezone configuration. Just follow on screen instructions to change the timezone.
If you are using Debian / Ubuntu Linux
To change the timezone for you run the following command as root user:
# dpkg-reconfigure tzdata
Again, just follow on screen instructions.
Share

Set date/time permanently on Virtualbox Guest

First you need to ssh to the server and be root and then do these step by step:

1. Set the date/time as following format

date -s “2 OCT 2013 18:00:00″

2. Set the proper Timezone for your area-

# cd /etc
# ln -sf /usr/share/zoneinfo/EST localtime

3. Set it to the BIOS for permanent stamp-

# /sbin/hwclock –systohc

On Debian/Ubuntu sytem:

dpkg-reconfigure tzdata

BDST NTP Server:

bsti1.time.gov.bd
bsti2.time.gov.bd

Use tzdata on Centos System:

To use it first download the tzdata package from the repo.

$ sudo yum -y install tzdata
$ tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
1) Africa
2) Americas
3) Antarctica
4) Arctic Ocean
5) Asia
6) Atlantic Ocean
7) Australia
8) Europe
9) Indian Ocean
10) Pacific Ocean
11) none – I want to specify the time zone using the Posix TZ format.
#?

Select a value and press the return key to proceed.

You will now be asked a country to select from the list provided.

Please select a country.
1) Aaland Islands 18) Greece 35) Norway
2) Albania 19) Guernsey 36) Poland
3) Andorra 20) Hungary 37) Portugal
4) Austria 21) Ireland 38) Romania
5) Belarus 22) Isle of Man 39) Russia
6) Belgium 23) Italy 40) San Marino
7) Bosnia & Herzegovina 24) Jersey 41) Serbia
8) Britain (UK) 25) Latvia 42) Slovakia
9) Bulgaria 26) Liechtenstein 43) Slovenia
10) Croatia 27) Lithuania 44) Spain
11) Czech Republic 28) Luxembourg 45) Sweden
12) Denmark 29) Macedonia 46) Switzerland
13) Estonia 30) Malta 47) Turkey
14) Finland 31) Moldova 48) Ukraine
15) France 32) Monaco 49) Vatican City
16) Germany 33) Montenegro
17) Gibraltar 34) Netherlands

Select and confirm the selection with 1 for Yes.

This completes the setup but to make it permanent you should add the following line to your ~/.bashrc file.

TZ=’Europe/London’; export TZ

Then log out and back in again.

The user can now log in and run the date command

$ date

Fri Jul 19 14:56:53 BST 20

On Centos 7

To list all available time zones, you can either list the files in the /usr/share/zoneinfo directory or use the timedatectl command.

timedatectl list-timezones
...
America/Tijuana
America/Toronto
America/Tortola
America/Vancouver
America/Whitehorse
America/Winnipeg
...

Once you identify which time zone is accurate to your location, run the following command as sudo user:

sudo timedatectl set-timezone your_time_zone

For example, to change the system’s timezone to America/Toronto:

sudo timedatectl set-timezone America/Toronto

Run the timedatectl command to verify the changes:

timedatectl
Local time: Wed 2019-02-06 17:47:10 EST
Universal time: Wed 2019-02-06 22:47:10 UTC
RTC time: Wed 2019-02-06 22:47:10
Time zone: America/Toronto (EST, -0500)
NTP enabled: no
NTP synchronized: yes
RTC in local TZ: no
DST active: no
Last DST change: DST ended at
Sun 2018-11-04 01:59:59 EDT
Sun 2018-11-04 01:00:00 EST
Next DST change: DST begins (the clock jumps one hour forward) at
Sun 2019-03-10 01:59:59 EST
Sun 2019-03-10 03:00:00 EDT
Share