Howto:linux Server Change OR Setup the Timezone

Source: Internet
Author: User
Tags time zones symlink time and date centos server

My Linux Systems TimeZone is pointing to the wrong timezone. How does I Setup or change the timezone under Linux operating systems?

Unix time, or POSIX time, is a system for describing points in Time:it is the number of seconds elapsed since midnight UT C on the morning of January 1, 1970, not counting leap seconds. The definition for time zones can being written in short form as utc?±n (or gmt?±n), where n is the offset in hours. You can use the following commands:

[A] setup or for redhat-config-date RHEL based distros.

[b] for dpkg-reconfigure tzdata Debian based distros.

[C] ln command –generic method for any other distros.

Command to change the Linux timezone

You need to type the following commands as per your Linux distribution.

If you is usingfedora/rhel/cent OS Linux

Type redhat-config-date the command line to start the time and Date Properties tool, run:
# redhat-config-date
OR type and setup select time zone configuration. This tool is recommended for remote SSH text based sessions.
# setup
Select timezone Configuration

Fig.01:redhat/centos Server Setting up Timezone
Just Follow on screen instructions to change the timezone.

If you is usingDebian/ubuntu Linux

The timezone for you run the following command as root user:
# dpkg-reconfigure tzdata
Again, just follow on screen instructions.

Set timezone using/etc/localtime configuration file [any Linux distro]

Often/etc/localtime is a symlink to the file localtime or to the correct time zone file in the system time zone directory .

Generic procedure to change timezone under Linux

Cd To/etc, run:
# cd /etc
Create a symlink to file localtime:
# ln -sf /usr/share/zoneinfo/EST localtime
OR some distro use/usr/share/zoneinfo/dirname/zonefile format (Red hat and friends):
# ln -sf /usr/share/zoneinfo/EST localtime
OR If you want to the set up it to IST (Asia/calcutta):
# ln -sf /usr/share/zoneinfo/Asia/Calcutta localtime
Please note this in above example-need to use directory structure i.e. if you want to set the timezone to Calcutta DIA) which is located in the Asia directory.

How does I verify new settings?

Use the date command to verify this your timezone is changed:
$ date
Output:

Tue 14:46:08 EST 2006
How does I use the environment variable called TZ?

You can use the TZ environment variable to display the date and time according to your timezone:
$ export TZ=America/Los_Angeles
$ date

Sample Output:

Thu 11:10:08 PST 2006
Transferred from: https://www.cyberciti.biz/faq/howto-linux-unix-change-setup-timezone-tz-variable/

Howto:linux Server Change OR Setup the Timezone

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.