On a Debian-family system, keep the system timezone identifier such as Europe/Berlin in a one-line text file.
Which path is representative?
Some distributions, including Debian-family systems, store the timezone identifier in /etc/timezone; formats vary by distribution.
Detailed explanation
/etc/localtimeIncorrect. /etc/localtime contains timezone data or a symlink.
Incorrect. /etc/localtime contains timezone data or a symlink.
/usr/share/zoneinfoIncorrect. /usr/share/zoneinfo is the database directory.
Incorrect. /usr/share/zoneinfo is the database directory.
/etc/locale.genIncorrect. /etc/locale.gen controls generated locales.
Incorrect. /etc/locale.gen controls generated locales.
/etc/timezoneCorrect. /etc/timezone commonly stores the identifier as text on Debian-family systems.
Correct. /etc/timezone commonly stores the identifier as text on Debian-family systems.
Try it yourself
An example you can run in a temporary verification environment.
if test -f /etc/timezone; then sed -n '1p' /etc/timezone; else printf '%s\n' 'not used on this distribution'; fiExpected result
timezone識別子、またはnot used on this distributionKey points
- Text identifier
- Distribution-dependent
- Different from /etc/localtime
Notes
- Environment: Linux / /etc/timezoneの読取のみ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.