howtouselinux

2 ways to change timezone in Linux

Table of Contents

Do you need to change your timezone on Linux for some reason? There are two ways that you can do this. In this blog post, we will discuss both methods and show you how to execute them. Changing your timezone can be a bit tricky, but with the help of this guide, you should be able to do it without any trouble!

change timezone with timedatectl command in Linux

The best way to change timezone in Linux is using timedatectl command. This command can be used to change both the timezone and date on your system. To change the timezone, you will need to use the following syntax: timedatectl set-timezone YOUR_TIMEZONE.

Replace “YOUR_TIMEZONE” with the actual timezone that you want to use. For example, if you want to set your timezone to America/Los_Angeles, you would use the following command: timedatectl set-timezone America/Los_Angeles

The timedatectl utility is distributed as part of the systemd system and service manager and allows you to review and change the configuration of the system clock. You can use this tool to change the current date and time, set the time zone, or enable automatic synchronization of the system clock with a remote server. Once you have executed the command, your timezone will be changed!

To list all available time zones, type the following at a shell prompt: timedatectl list-timezones

change timezone by editing /etc/localtime file in Linux

The second method to change your timezone in Linux is by editing the /etc/localtime file. This file contains your system’s current timezone information. The /etc/localtime file is a link to the original time zone file found under the/usr/share/zoneinfo directory.

ls -al /etc/localtime
lrwxrwxrwx. 1 root root 36 Dec 2 22:01 /etc/localtime -> /usr/share/zoneinfo/America/New_York

The /usr/share/zoneinfo/ directory contains all the time zones. Beneath that you can find directories specific to country or zone. For example, the /usr/share/zoneinfo/America/ directory contains American time zones.
ls /usr/share/zoneinfo/America/

Advertisements

Now, create a link with the desired time zone. In my case, for Central Standard Time (CST) timezone.

ln -sf /usr/share/zoneinfo/US/Eastern /etc/localtime
or
ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime

Here, you can link either the City or Zone with /etc/localtime. Chicago falls under Central Standard Time (CST).

FAQ about timezone in Linux

Question: How can I find the current timezone that my system is using?
Answer: To find the current timezone that your system is using, type the following command at a shell prompt: timedatectl status

What are the available time zones that I can use?
To list all available time zones, type the following at a shell prompt: timedatectl list-timezones

These are two methods that you can use to change your timezone on Linux. If you have any questions or need help, feel free to leave a comment below! Thanks for reading!

Facebook
Twitter
LinkedIn

Loom is a video messaging tool that helps you get your message across through instantly shareable videos.

With Loom, you can record your camera, microphone, and desktop simultaneously. Your video is then instantly available to share through Loom’s patented technology.