Changing the Time Zone in the Linux Shell
Learn how to set a specific time zone for your Linux shell account using the TZ environment variable.
By default, a Linux shell uses the host server's time zone. If you are in a different time zone, you can override this setting with TZ.
| Important Ruachost.com servers are located in the US Eastern Standard Time (EST) zone. |
The TZ environment variable affects file and directory timestamps as well as the output of the date command. For example, to set the time zone to California:
export TZ="/usr/share/zoneinfo/America/Los_Angeles"
To make this change permanent for future logins, add the line above to your ~/.bash_profile or ~/.bashrc file.
| Tip To see all available time zones on the server, use the tzselect program. It lets you choose a time zone based on your region and country, and then you can set the corresponding TZ value in your shell profile file. |
For a complete list of time zones, visit:
Wikipedia: List of tz database time zones