Skip to content

Changing the time zone in the Linux shell

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.

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 Lagos, Nigeria:

Terminal window
export TZ="Africa/Lagos"

To make this change permanent for future logins, add the line above to your ~/.bash_profile or ~/.bashrc file.

For a complete list of time zones, visit:
Wikipedia: List of tz database time zones

Was this page helpful?