What's the difference between localtime and timezone files?
/etc/timezone
is a text-based representation of what timezone you are in. This could be expressed as an offset from GMT/UTC, but more often it's the path under /usr/share/zoneinfo
that points to the appropriate timezone data file (for example, if you're in most places in the eastern US, this will be America/New_York
or US/Eastern
). The main purpose of this is to make sure that /etc/localtime
gets updated correctly when the data files in /usr/share/zoneinfo
are updated (although some systmes make /etc/localtime
a symbolic link pointing to the correct file there), and to provide a quick user-friendly name for the timezone (US/Eastern is a lot more user friendly than EST or EDT). Only some systems actually use this file.
/etc/localtime
is a binary representation of the exact rules for calculating the time relative to UNIX time (the internal representation used by the kernel, which is measured as seconds since 1970-01-01 00:00:00 UTC). This includes things like the normal offset from UTC, as well as the rules for when daylight-savings-time (if you're in an insane municipality that observes it) starts and ends and what offset that applies, as well as encoding the rules for leap day, and annotating how may leap seconds have been observed. This is what gets used by things like the date
command (and it's equivalent functions in various programming languages) to show you exactly what time it is locally. All Linux systems with a conventional userspace use this file.