In the following of CentOS 6 Linux introductory tutorials, we are going to learn you how to set Timezone on CentOS 6 Linux and work with the date command. To set the time and date of your system, all you have to do is specify your time zone so that CentOS Linux automatically adjusts the time of your system from the time servers.
First, use the date command to view the date of your current system and time zone.
date
When you enter the date command, you will see the time information of your system. In this notification, in addition to the time and clock of your system, it shows the time which is already set for your operating system. Use the following commands to change and adjust your time zone.
Set Timezone on CentOS 6 Linux
1- First, delete the file where your time zone is currently stored.
rm -rf /etc/localtime
2- Then specify your time zone with the following command.
Command Structure
ln -s /usr/share/zoneinfo/"Time_Zone" /etc/localtime
Example:
ln -s /usr/share/zoneinfo/America/NewYork /etc/localtime
In the above example, we have selected the time zone of NewYork. You can use different sites to get the time zone and its name.
After going through the above steps, you need to change the time zone of your system’s hardware clock.
3- Open the etc/sysconfig/clock file with the vi editor.
vi /etc/sysconfig/clock
4- In the opened file, enter the following statement.
ZONE="America/NewYork" UTC=false ARC=false
Finally, save the file by hitting the Esc key and entering the phrase :wq
Please note: You must enter your desired time zone in the first line.
5- Enter the following command to write the changes made in the hardware clock.
hwclock --systohc --localtime
6- You can use the following command to ensure that the changes are applied.
hwclock
At this point the settings are complete and you can see your date and time by entering the date command, like below command.
date
Dear user, we hope you would enjoy this tutorial, you can ask questions about this training in the comments section, or to solve other problems in the field of Eldernode training, refer to the Ask page section and raise your problems in it.