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!
Table of Contents
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:
Get Your Free Linux training!
Join our free Linux training and discover the power of open-source technology. Enhance your skills and boost your career! Learn Linux for Free!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
Related: 3 ways to get time in Linux
Procedures to change timezone in Linux
- Open the terminal and type timedatectl, then press Enter. This will show you the current time, date, and time zone.
- To change the time zone, type timedatectl set-timezone followed by the name of the time zone you want to use. For example, to change to the Pacific time zone, you would type timedatectl set-timezone America/Los_Angeles.
- Press Enter, and the time zone will be updated. You can type timedatectl to check that the change was successful.
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.
we can use this command to list all the timezone in Amerca
ls /usr/share/zoneinfo/America/
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).
Related: 4 Ways to check last reboot time in Linux
FAQ about timezone in Linux
Question: How can I find the current timezone that my system is using in Linux?
Answer: To find the current timezone that your system is using in Linux, type the following command at a shell prompt: timedatectl status
What are the available time zones that I can use in Linux?
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!