Time/Date Operations with timedatectl

Screen Shot 2019-05-31 at 15.14.26.png

One of the recently introduced commands in modern Linux distros is timedatectl. It’s a convenient way to review and configure time, date and timezone information. I noticed wrong time on one of my Raspberry Pi systems and used this opportunity to learn how timedatectl is used.

Show Current Time and Date Info with timedatectl

Run the command without any options to see current status:

greys@becky:~ $ timedatectl
Local time: Fri 2019-05-31 14:01:04 UTC
Universal time: Fri 2019-05-31 14:01:04 UTC
RTC time: n/a
Time zone: Etc/UTC (UTC, +0000)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no

List Timezones with timedatectl

Run timedatectl list-timezones to see all the available timezones. I used the following command line to confirm timezone for Dublin, Ireland:

greys@becky:~ $ timedatectl list-timezones | grep Europe | head -20
Europe/Amsterdam
Europe/Andorra
Europe/Astrakhan
Europe/Athens
Europe/Belgrade
Europe/Berlin
Europe/Bratislava
Europe/Brussels
Europe/Bucharest
Europe/Budapest
Europe/Busingen
Europe/Chisinau
Europe/Copenhagen
Europe/Dublin
Europe/Gibraltar
Europe/Guernsey
Europe/Helsinki
Europe/Isle_of_Man
Europe/Istanbul
Europe/Jersey

Change Timezone with timedatectl

Let’s update timezone to Europe/Dublin.

If you try running it as regular user, it won’t work:

greys@becky:~ $ timedatectl set-timezone Europe/Dublin
==== AUTHENTICATING FOR org.freedesktop.timedate1.set-timezone ===
Authentication is required to set the system timezone.
Multiple identities can be used for authentication:
1. ,,, (pi)
2. root
^C

so use sudo command to run it:

greys@becky:~ $ sudo timedatectl set-timezone Europe/Dublin

… and then check status again:

greys@becky:~ $ timedatectl
Local time: Fri 2019-05-31 15:04:33 IST
Universal time: Fri 2019-05-31 14:04:33 UTC
RTC time: n/a
Time zone: Europe/Dublin (IST, +0100)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no

Perfect!

See Also