The ln command is used to create file links, while the -s flag is used to set the link type as symbolic and the -f flag forces the creation, which is required to update an existing link. sudo ln -sf /usr/share/zoneinfo/America/Phoenix For example: rootrhel7 timedatectl list-timezones grep -i bratislava Europe/Bratislava In the last step we simply use timedatectl command to set new timezone. To change the timezone, replace the symbolic link with that of the correct timezone file for your server. The following linux command will list all timezones: rootrhel7 timedatectl list-timezones To narrow down the search you can use grep to search for a specific city. In the example above, we can see the /etc/localtime file is symbolically linked to the America/Toronto timezone file. Requires > Puppet 3.2. Works on RHEL/CentOS, Amazon Linux, SUSE, Debian, Ubuntu and Gentoo. ls -la /etc/localtime lrwxr-xr-x 1 root wheel 41 30 Aug 22:12 /etc/localtime -> /var/db/timezone/zoneinfo/America/Toronto A very basic Puppet module to set the timezone properly. To get a basic view of the timezone you can ls the file to it’s symbolic link. This file is actually a symbolic link to a timezone file under /usr/share/zoneinfo. The timezone on a RedHat and CentOS server is stored set by the /etc/localtime file.
sudo timedatectl set-timezone America/Phoenix Setting Timezone with Symbolic Link For example, to set the server’s timezone to America/Phoenix, you would run the following command. Once you have the timezone you want to set the system to, you use the timedatectl set-timezone command with the name of the timezone. timedatectl list-timezones | grep America. If you have an idea which timezone you want, you can pipe timedatectl into the grep command. Additional Information These manual changes WILL be lost if updates are applied to the system that do not contain the corrected timezone information. You could browse the list by piping the timedatectl command into the less command. timedatectl list-timezones Africa/Abidjan You can view a list of supported timezones using the timedatectl list-timezones command. In order to set your timezone you should probably list the available zones. mv /etc/localtime /root/localtime.old ln -s /usr/share/zoneinfo/America/LosAngeles /etc/localtime Your timezone has been changed successfully. For example we are setting America/LosAngeles as our local system timezone.
In the example below, we can see the server’s time zone is America/New_York, and the offset is -0400. To change timezone on CentOS/RHEL 6/5 we can simply link /etc/localtime file with correct timezone configuration file.
To get detailed information your CentOS server’s date, time, and timezone you use the timedatectl command.
You will also learn how to view this linked file and how to update your timezone by changing the link. The timedatectl command is a relatively new addition to Systemd distributions, and provides a much simpler interface for viewing and adjusting a server’s date and time.ĬentOS and RedHat still use symbolically linked files to set the system’s timezone. In this tutorial, you will learn how to check and set your Timezone in CentOS.