To set the time zone on a per-user basis in Linux or Unix, you can use the TZ
environment variable. You can set this variable in the user's shell configuration file, such as .bashrc
or .bash_profile
, depending on the shell being used.
For example, to set the time zone to America/New_York for the Bash shell, you can add the following line to the .bashrc
file in the user's home directory:
export TZ='America/New_York'Source:l.wwwautturi.com
Once you have set the TZ
variable in the appropriate configuration file, the time zone will be set for the user every time they log in or start a new shell session.
Note that the time zone must be specified in the format 'Continent/City', and the list of valid time zones can be found in the /usr/share/zoneinfo
directory on most systems.
Alternatively, you can use the tzselect
command to interactively select the desired time zone. This command will guide you through a series of prompts to select the appropriate region and city, and will output the appropriate value for the TZ
variable.