Raspberry PI

Change timezone in Raspberry PI OS Lite from terminal

One of main actions after installing your Raspberry PI OS regards configuring timezone, to show correct time in your system.

This guide will help you in performing this setting from terminal. This guide applies both to Raspberry PI OS Lite installation and Raspberry PI OS Desktop installation.

Setup Timezone

Raspberry PI OS, like Debian, includes timezone files in the /usr/share/zoneinfo directory tree, which is provided by the tzdata package.

Looking at this directory:

pi@raspberrypi:~ $ cd /usr/share/zoneinfo/
pi@raspberrypi:/usr/share/zoneinfo $ ls
Africa Brazil Egypt GB Hongkong Jamaica Mexico Poland ROC US
America Canada Eire GB-Eire HST Japan MST Portugal ROK UTC
Antarctica CET EST GMT Iceland Kwajalein MST7MDT posix Singapore WET
Arctic Chile EST5EDT GMT+0 Indian leap-seconds.list Navajo posixrules SystemV W-SU
Asia CST6CDT Etc GMT-0 Iran Libya NZ PRC Turkey zone1970.tab
Atlantic Cuba Europe GMT0 iso3166.tab localtime NZ-CHAT PST8PDT UCT zone.tab
Australia EET Factory Greenwich Israel MET Pacific right Universal Zulu

To check current local time, please you can verify what timezone file is pointed by /etc/localtime link:

pi@raspberrypi:~ $ ls -l /etc/localtime
lrwxrwxrwx 1 root root 33 Jun 20 15:41 /etc/localtime -> /usr/share/zoneinfo/Europe/London

To change local time, you can use the convenient tzdata. From terminal, type command:

sudo dpkg-reconfigure tzdata

This command will enable Configuring tzdata wizard:

Please select your geographic area and press ENTER key.

Please select your time zone (Rome in my case) and press ENTER. Wizard will exit and your new config will be confirmed in following terminal message:

pi@raspberrypi:~ $ sudo dpkg-reconfigure tzdata

Current default time zone: 'Europe/Rome'
Local time is now: Sat Jun 20 17:19:49 CEST 2020.
Universal Time is now: Sat Jun 20 15:19:49 UTC 2020.

New configuration will be also confirmed from /etc/localtime link:

pi@raspberrypi:~ $ ls -l /etc/localtime
lrwxrwxrwx 1 root root 31 Jun 20 17:19 /etc/localtime -> /usr/share/zoneinfo/Europe/Rome

Same wizard can also be found with raspi-config (run with sudo) -> Localisation Options -> Change Time Zone.

Enjoy!

Check hardware prices with following links:

peppe8o

Open source and Raspberry PI lover

Published by
peppe8o

Recent Posts

Some links in this post may be affiliate links. We may get paid if you buy something or take an action after clicking one of these, but without addictional costs for you compared to direct buying.

SPI communication between two Arduinos

In this tutorial, we will use two Arduino Uno to demonstrate the Serial Peripheral Interface…

2 weeks ago

Automatic irrigation system with Arduino and Sensors

In this tutorial, we will be making an automatic irrigation system (AIS) with Arduino and…

3 weeks ago

Beginner’s Guide to Use Python Virtual Environment with Raspberry PI (venv)

This tutorial will show you how to use Python Virtual Environment with Raspberry PI computer…

4 weeks ago

Get Betting Odds with Raspberry PI and Odds-API (free)

This tutorial will show you how to get betting odds with Raspberry PI by using…

1 month ago

Backup Raspberry PI (computer) Data with Rsync to Remote NAS

This tutorial will show you how to perform the backup of Raspberry PI (computer board)…

1 month ago

Honeygain and Raspberry PI: Earn by Sharing Internet Connection

This tutorial will show you how to install Honeygain on a Raspberry PI computer board…

1 month ago