How to Set or Change the Time Zone in Linux?

How to Set or Change the Time Zone in Linux?

This Linux tutorial explains how to set or change the time zone in Linux. A time zone is a geographic region that has the same standard time. Using the correct time zone is essential for many systems related tasks and processes. This tutorial covers the steps necessary to set or change the time zone in Linux.

A time zone is a geographic region that has the same standard time. Typically the time zone is set during the installation of the operational system, but it can be easily changed at a later time.

Using the correct time zone is essential for many systems related tasks and processes. For example, the cron daemon uses the system's time zone for executing cron jobs. The time zone is also used for logs timestamps.

This tutorial covers the steps necessary to set or change the time zone in Linux.

Checking the Current Time Zone

timedatectl is a command-line utility that allows you to view and change the system's time and date. It is available on all modern systemd-based Linux systems.

To view the current time zone, invoke the timedatectl command without any options or arguments:

timedatectl

                      Local time: Tue 2019-12-03 16:30:44 UTC
                  Universal time: Tue 2019-12-03 16:30:44 UTC
                        RTC time: Tue 2019-12-03 16:30:44
                       Time zone: Etc/UTC (UTC, +0000)
       System clock synchronized: no
systemd-timesyncd.service active: yes
                 RTC in local TZ: no

The output above shows that the system's time zone is set to UTC.

The system time zone is configured by symlinking the /etc/localtime file to a binary time zone's identifier in the /usr/share/zoneinfo directory.

Another way to check the time zone is to view the path the symlink points to using the ls command:

ls -l /etc/localtime

lrwxrwxrwx 1 root root 27 Dec  3 16:29 /etc/localtime -> /usr/share/zoneinfo/Etc/UTC

Changing the Time Zone in Linux

Before changing the time zone, you'll need to find out the long name of the time zone you want to use. The time zone naming convention usually uses a “Region/City” format.

To view all available time zones, use the timedatectl command or list the files in the /usr/share/zoneinfo directory:

timedatectl list-timezones

...
America/Montserrat
America/Nassau
America/New_York
America/Nipigon
America/Nome
America/Noronha
...

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

sudo timedatectl set-timezone <your_time_zone>

For example, to change the system's timezone to America/New_York you would type:

sudo timedatectl set-timezone America/New_York

To verify the change, invoke the timedatectl command again:

timedatectl

                      Local time: Tue 2019-12-03 13:55:09 EST
                  Universal time: Tue 2019-12-03 18:55:09 UTC
                        RTC time: Tue 2019-12-03 18:02:16
                       Time zone: America/New_York (EST, -0500)
       System clock synchronized: no
systemd-timesyncd.service active: yes
                 RTC in local TZ: no

Mission accomplished! You've successfully changed your system's time zone.

Changing the Time Zone by Creating a Symlink

If you are running an older Linux distribution and the timedatectl utility is not present on your system, you can change the timezone by symlinking /etc/localtime to the time zone in the /usr/share/zoneinfo directory.

Remove the current symlink or file:

sudo rm -rf /etc/localtime

Identify the timezone you want to configure and create a symlink:

sudo ln -s /usr/share/zoneinfo/America/New_York /etc/localtime

Verify it either by listing the /etc/localtime file or invoking the date command:

date

The output includes the time zone, in this example that is “EST”.

Tue Dec  3 14:10:54 EST 2019

Conclusion

To change the time zone in Linux systems use the sudo timedatectl set-timezone command followed by the long name of the time zone you want to set.

Feel free to leave a comment if you have any questions.

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

What’s new in HTML6

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Linux Tutorial for Beginners | What is Linux | Intellipaat

Linux Tutorial for Beginners | What is Linux | Intellipaat

🔥Intellipaat Linux Course: https://intellipaat.com/linux-training/ In this linux tutorial for beginners video you will learn what is linux, how to install li...

In this linux tutorial for beginners video you will learn what is linux, how to install linux, how to setup kernel parameters, how to install & remove softwares, RPM in linux, various commands in linux and various linux services & systemd in detail.

Why should you watch this Linux Tutorial?

Linux is a powerful open-source operating system that is being used by a large section of the corporate world. This OS ensures that you have the power to configure, manage and secure your systems. We are offering the top linux tutorial that has been created with extensive inputs from the industry experts so that you can learn linux easily.

Who should watch this Linux Tutorial video?

Since this linux video with hands on can be taken by anybody, so if you are a software engineers and IT professionals, linux developers and administrators or a beginner in technology then you must watch this linux tutorials to take your skills to the next level.

Why should you opt for a Linux career?

If you want to fast-track your career then you should strongly consider linux. The reason for this is that it is one of the fastest growing technology. There is a huge demand for professionals in linux. The salaries for linux Professionals is fantastic.There is a huge growth opportunity in this domain as well. Hence this Intellipaat linux tutorial, is your stepping stone to a successful career!

Linux Audio Survival kit. - Linux Audio Survival Kit

A brief guide to have success setting up the audio in Linux.

A brief guide to have success setting up the audio in Linux.

Kali Linux 2020.1 | The Best Linux Distro For Hacking

Kali Linux 2020.1 | The Best Linux Distro For Hacking

Advanced penetration testing and cybersecurity distro, Kali Linux has released this year's first version. Kali 2020.1 is out and in this video, we'll be having a detailed look at this exceptional distro that comes with state-of-the-art hacking and cyber forensics tools.

Advanced penetration testing and cybersecurity distro, Kali Linux has released this year's first version. Kali 2020.1 is out and in this video, we'll be having a detailed look at this exceptional distro that comes with state-of-the-art hacking and cyber forensics tools.

I've been playing around with Kali 2020.1 from some time, mainly because, in the last 6 months, Kali has undergone pretty innovative changes like the default non-root credentials, undercover mode, and Kali's interest in being deployed as the main primary OS for its users.

Download Kali Linux 2020.1:
https://www.kali.org/downloads