Should /etc/localtime be a file or a symlink ?
As installed, /etc/localtime is a copy of one of the files in /usr/share/zoneinfo.
If I change the system's timezone, using a system-config-date, I also get a copy of one of these files.
The reasons I've seen for making this a file is that otherwise yum update might mess up the settings.
Browsing the internet, however, I get a large number of recommendations to make /etc/localtime a symlink to the zoneinfo file.
Supposedly, this helps in determining the currently active timezone. Note that the info /etc/zoneinfo is not always correct on the systems I manage.
What is the accepted best practice here ? File or symlink ? And why ?
Responses
I can only offer what I see on my systems. On RHEL-6, /etc/localtime is a copy.
$ rpm -qf /etc/localtime
glibc-2.12-1.149.el6.x86_64
As you mentioned, there are some arguments against making this a symlink.
However, on RHEL-7, it is a symbolic link.
$ rpm -qf /etc/localtime
systemd-208-11.el7_0.4.x86_64
Looks as if it is related to the systemd stuff.
Couple of things to bear in mind:
* In general, you want to keep RPM-delivered files the same as what was delivered via RPM (depending on your security auditors, if it's not, the auditors' security scripts will alert on the difference and then you get to deal with the joy of explaining/justifying "why").
* Depending what types of tools you use for system configuration management, setting the file to a symlink may not hold up over time (this is more likely with tools that use the equivalent of a sed -i to maintain files' contents)
Hello
This article recommends against using a symlink in RHEL6 and earlier. It also has some discussion on the subject in the comments. How to change the system time zone from command line in Red Hat Enterprise Linux 6 and earlier
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
