The geographic timezone names are both an abstraction and a convenience. Under the hood, the timezone data files are binaries which list offsets, discontinuities and DST changes but not location (even if the filename indicates it, hence the problem with /etc/localtime). There is a mapping from location and date to timezone offsets, but it's not 1:1 – given the output of date for example, you cannot easily and deterministically derive the geographic location in use (but you could compute a set of compatible ones for the current date; or you could, with some effort, inspect earlier dates for discontinuities in order to deduce a location).
There is a master list of zone names, and the timezone definition files look like:
# Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Europe/London -0:01:15 - LMT 1847 Dec 1 0:00s 0:00 GB-Eire %s 1968 Oct 27 1:00 - BST 1971 Oct 31 2:00u 0:00 GB-Eire %s 1996 0:00 EU GMT/BST Link Europe/London Europe/Jersey Link Europe/London Europe/Guernsey Link Europe/London Europe/Isle_of_Man
When creating the binary Europe/London file the indicated rules are processed to build the time rules (the timestamps where something changes, inspect with zdump -v Europe/London), and the related locations are aliased. The localtime file contents or date output from any of the above locations will be indistinguishable.
The abstraction lets you handle legal changes in time, such as
# TZ=Europe/Andorra date -d "Aug 31 1984" Fri Aug 31 00:00:00 CET 1984 TZ=Europe/Andorra date -d "Aug 31 1985" Sat Aug 31 00:00:00 CEST 1985
(Andorra is not in the EU, but follows EU DST rules since 1985)
/etc/localtime is the (binary) timezone data file, on Debian by convention it should be a symlink to the named geographic timezone file according to the ''Stretch'' (9) and ''Buster'' (10) localtime man pages:
The /etc/localtime file configures the system-wide timezone of the local system that is used by applications for presentation to the user. It should be an absolute or relative symbolic link pointing to /usr/share /zoneinfo/, followed by a timezone identifier such as "Europe/Berlin" or "Etc/UTC". The resulting link should lead to the corresponding binary tzfile(5) timezone data for the configured timezone.
Because the timezone identifier is extracted from the symlink target name of /etc/localtime, this file may not be a normal file or hardlink.
Assuming that's the case:
if [ -L /etc/localtime ]; then IFS=/ read -a TZFILE < <(readlink -f /etc/localtime) printf -v TZNAME "%s/%s\n" ${TZFILE[-2]} ${TZFILE[-1]} echo $TZNAME fi
In earlier versions (or if someone has not been following the documentation) it was a copy of the timezone data file. So, to verify that /etc/localtime and /etc/timezone are in agreement you need to compare them:
$ diff -s /etc/localtime /usr/share/zoneinfo/`cat /etc/timezone` Files /etc/localtime and /usr/share/zoneinfo/America/New_York are identical
If you need to work backwards, or be thorough:
read CHECK file < <(sha256sum /etc/localtime) while read sum file; do [[ "$sum" == "$CHECK" ]] && printf "%s\n" "$file" done < <(find /usr/share/zoneinfo/ -type f |xargs sha256sum)
This isn't a truly portable answer (POSIX doesn't define or require these long names, they come from ICANN/IANA), and you're using systemd commands on those versions of Debian.