LinuxCommandLibrary

tzselect

Select a timezone interactively

TLDR

Open the interactive menu for timezone selection and print the selected timezone to stdout

$ tzselect
copy

Ask for nearest timezone to coordinates in ISO 6709 notation
$ tzselect -c [coordinates]
copy

SYNOPSIS

tzselect

DESCRIPTION

tzselect is an interactive utility designed to help users determine the correct timezone string for their geographical location. It guides the user through a series of hierarchical menus, first prompting for a continent or ocean, and then progressively narrowing down the selection to specific regions or major cities within that area. Once a selection is made, tzselect outputs the corresponding canonical timezone identifier (e.g., "America/Los_Angeles") to standard output. This output is typically used to configure the system's timezone, often by setting the TZ environment variable or by creating a symbolic link from /etc/localtime to the appropriate timezone data file found in /usr/zoneinfo. It simplifies the process of timezone configuration, especially for new users or systems without a graphical interface, by abstracting away the need to know the exact timezone string format. It relies on the tzdata package for its comprehensive timezone information.

CAVEATS

tzselect only outputs the recommended timezone string to standard output; it does not automatically set the system's timezone. The user must manually use its output to configure the system (e.g., by creating a symbolic link for /etc/localtime or setting the TZ environment variable).
Being an interactive command, it is generally unsuitable for direct use within automated scripts without advanced input redirection techniques.
Its functionality is entirely dependent on the presence and up-to-date nature of the tzdata (timezone data) package on the system.

INTERACTIVE NATURE

tzselect functions as an interactive shell script, guiding the user through a sequence of numbered menus. It first prompts for a continent or ocean, followed by more specific regions or cities. This interactive approach ensures an accurate timezone selection without requiring prior knowledge of specific timezone identifiers. Due to its interactive nature, it does not accept command-line arguments or options.

OUTPUT USAGE

The primary utility of tzselect lies in its ability to output the canonical timezone name to standard output upon successful selection. Users typically capture this output using command substitution (e.g., $(tzselect)) to then manually configure their system's timezone. Common configuration methods include updating the /etc/localtime symbolic link (e.g., sudo ln -sf /usr/share/zoneinfo/$(tzselect) /etc/localtime) or setting the TZ environment variable for specific shell sessions or applications.

HISTORY

tzselect is an integral part of the tzdata (timezone data) distribution, also widely known as the IANA Time Zone Database or the Olson database. This comprehensive database was initially created by Arthur David Olson in 1987 and subsequently maintained by Paul Eggert. tzselect was developed to provide a user-friendly, interactive method for navigating this extensive and often complex database. Its primary purpose is to allow system administrators and users to easily identify and configure their correct local time, a crucial aspect for globally distributed systems. Its design prioritizes simplicity and interactivity, abstracting the underlying file system structure of the timezone data to make configuration accessible.

SEE ALSO

date(1), timedatectl(1), zdump(8), zic(8), localtime(5), tzfile(5)

Copied to clipboard