Ubuntu: Set the Timezone from the Terminal

Two Commands

List what is available:

timedatectl list-timezones

That is a long list. Narrow it:

timedatectl list-timezones | grep -i brisbane

timedatectl is a systemd tool, which means this works on any modern Ubuntu, Debian, Fedora, Arch or Raspberry Pi OS — no dpkg-reconfigure dance, no editing /etc/timezone by hand.

Set it:

sudo timedatectl set-timezone Australia/Brisbane

Verify:

timedatectl
date

The output shows the local time, universal time, the RTC time and whether NTP synchronisation is active. If NTP synchronized: yes and the offset is small, you are done.

A photorealistic shot of a laptop showing a terminal with timedatectl output including the timezone line, a clock on the wall behind it, warm office light, realistic photography, no legible text.

Getting The Name Right

The value is a Region/Location pair from the tz database — Australia/Brisbane, Europe/London, America/New_York. Not abbreviations.

AEST and EST are not valid and will produce:

Failed to set time zone: Invalid or not found time zone

That is worth understanding because abbreviations are ambiguous. CST is Central Standard Time in the US, China Standard Time, and Cuba Standard Time — three different offsets. The tz database uses geographic names precisely because they are not ambiguous, and because they carry the historical and future daylight-saving rules for that place.

Use the list rather than guessing:

timedatectl list-timezones | grep -i '^Australia/'

What Actually Changes

Setting the timezone does not change the system clock or the hardware clock. It changes how the same UTC instant is displayed to users and applications.

That distinction explains a lot of confusing behaviour:

  • Log timestamps shift to local time
  • Cron jobs run against the new local time — a job at 0 3 * * * now fires at 3am local, not 3am in the old zone
  • Already-running services may keep the old timezone until restarted

That last one catches people. timedatectl changes the system setting immediately, but a long-running process that cached the timezone at startup will keep using the old value. If a service's timestamps look wrong after a change, restart it.

Timezone In Containers And Applications

The host timezone is not automatically inherited everywhere.

Docker containers default to UTC unless you tell them otherwise:

docker run -e TZ=Australia/Brisbane yourimage

Or in a compose file:

environment:
  - TZ=Australia/Brisbane

Also make sure tzdata is installed in the image; a slim base image may not have it, in which case TZ is ignored.

PostgreSQL stores timestamps as UTC but renders them in a session timezone, which comes from the server config rather than the OS after startup. Set timezone in postgresql.conf or per session.

Java and Python applications may read the OS timezone at start and cache it. A restart is usually required.

Raspberry Pi devices are the same as any Ubuntu system — timedatectl works. A headless Pi with no network comes up in UTC and never corrects, which is a common reason for timestamps in sensor logs being eight hours out.

Keeping It Accurate

A correct timezone still shows the wrong time if the clock drifts:

timedatectl status

Look for System clock synchronized: yes and a small NTP service: active. If NTP is inactive:

sudo timedatectl set-ntp true

For a machine with no reliable network, or an embedded device that boots offline, install fake-hwclock so the clock does not reset to 1970 on every boot — otherwise every log entry from before the first successful NTP sync is dated 1970, which makes them effectively unsearchable.

A photorealistic close-up of a Raspberry Pi beside a laptop showing a terminal with a date command and its output, a small clock display nearby, warm workshop light, realistic photography, no legible text.

A photorealistic shot of a laptop showing a terminal with the timezone list filtered by a region, a wall clock behind it, morning light, realistic photography, no legible text.

Pin It Down Or You Will Forget

The version with the region commented, so that in eighteen months you know why it was set:

timedatectl set-timezone Australia/Brisbane

and to double check every machine in one pass:

timedatectl | grep 'Time zone'

On a fleet, that one line is faster than opening a settings app on each host.

Don't trust the download button. Trust the hash.

If this was useful, More hands-on tech guides at TechGeek. No pressure — read it whenever it's useful.


Luke Keam
Spot a bug or want a custom utility built? I'd love to hear from you. Get in touch
Luke Keam | techgeek.biz