As a Linux server administrator, you must know how to change the system date and time and also modify time zones in Linux. This task is crucial as it helps maintain accurate timestamps for the proper functionality of applications and services.
You might be involved in managing a personal project or overseeing a complete production environment; learning how to adjust the system clock in a Linux environment is important.
In this knowledge base, we will discuss various processes, from setting the time manually to configuring your server to synchronize with network time servers using protocols like NTP (Network Time Protocol) or using a combination of commands and the command line to ensure your Linux system reflects the correct local time.
Also Read: How To Access Linux Server Using PuTTY SSH Terminal?
Ways to Change Server Time in Linux
➢ Menu-Driven Selection of Time Zone
The tzselect in Linux is an important utility that helps users choose a timezone from a selection of regions and cities. It generates a description of the selected timezone, which can be utilized as the value for the TZ environment variable.
It is important to understand that tzselect does not permanently alter the system’s timezone. It has a short-term influence on the current shell session.
If you wish to deploy permanent changes to the system timezone, you must use alternative methods like timedatectl or create symlinks.
Note: Towards the end of this prompt, you’ll find information explaining to you about making your tzselect choice persistent.
➔ Let’s run the command: tzselect

➔ You can select 8 for the Indian Ocean, followed by selecting your country.

➔ Please select Country Number for Country Name

➔ The next screen will show the chosen selection and prompt you to verify that the information is accurate.

➔ After confirmation, you can review the updated details on the next screen. This screen also offers instructions on how to make the change permanent by adding a line to the .profile file in your Home Directory.

Also Read: How to Create a User in Linux & Add it to the sudoer File?
➢ Using the timedatectl to change the Time Zone
The timedatectl command-line utility enables you to view and modify the system’s time, date, and timezone. Additionally, it can synchronize the system clock with a remote server via the Network Time Protocol (NTP). timedatectl is an integral component of the Systemd system and service manager.
Check out all available time zones. You can use the following command: timedatectl list-timezones

Given the extensive list, you can use the command timedatectl list-timezones | grep IST to discover the IST value. It is easy to change IST to your preferred timezone. Your command can be like:

Making changes to Region/Location
You may use the command sudo timedatectl set-timezone Region/Location to change the present Region/Location to your preferred one.
➢ Manually Setting the Date and Time in Linux
To set a new date and time manually in Linux, use the following syntax:
Date -s=”Date and time information”
date -s “12 August 2024 08:46:00”

Also Read: What if I Exceed the Bandwidth Limit that I am Assigned to VPS?
➢ Modifying Timezone in Linux
The file /etc/localtime is responsible for setting the system-wide timezone for the local machine, which applications utilize. It should be represented as an absolute or relative symbolic link that points to /usr/share/zoneinfo/, followed by a specific timezone identifier, such as “Asia/Kolkata” or “Etc/UTC.”
Note: UTC is Coordinated Universal Time. India uses UTC+5:30, which is referred to as Asia/Kolkata.
The directory /usr/share/zoneinfo houses files that provide information about various timezones. Each file is named after its corresponding timezone, such as “America/New_York” or “Asia/Kolkata.” These files preserve details regarding timezone rules and the settings for Daylight Saving Time (DST) applicable to each specific timezone.
Please check the contents of cat/etc/localtime from the following image.

Please check the contents of ls /usr/share/zoneinfo from the following image.

By creating this link, a file named “localtime” will be generated in the directory from which you execute the command. Any other tool that you use to modify the timezone later on will be ineffective, as this link will override any other settings.
To address this issue, you can simply remove the “localtime” link or file when necessary.
Please use the following command.
ln -sf /usr/share/zoneinfo/Asia/Kolkata localtime
date

Also Read: How to Check if My Server is Under DDoS Attack
Conclusion
As it is clearly visible from this knowledgebase, changing the server time in Linux is a straightforward process. This process is crucial for maintaining accurate system operations and ensuring proper scheduling of tasks.
By utilizing commands such as timedatectl or manually adjusting the timezone file, administrators can effectively set the correct time and timezone for their systems. It’s essential to synchronize your server time with Network Time Protocol (NTP) servers to ensure continuous accuracy.
Following the procedures mentioned in this blog will help you enhance system reliability and prevent issues related to data integrity and application performance.
Administrators must regularly monitor and update server time settings for optimal server management in any Linux environment.