DEV Community

loading...

Write-up: KodeKloud Sysadmin (Set or Change System's Timezone in Linux)

Artur Serra
Software Engineer, Cybersecurity Graduate, MBA in Cybersecurity Student | Constantly researching about blockchain and cloud technologies | He/Him
・2 min read

In this task, proposed here, the sysadmin has to change the timezone in the system, to fit Australia/Brisbane. In this post, we'll go through the process to do so in the most recent Linux distributions.

For starters, you gotta check which timezone your system is currently set. Usually it's defined during the installation process, and it's important for a lot of system-related processes and tasks, like cron-jobs and application logs. To view your current timezone, run the command:

$ timedatectl

It should return to you a lot of information related to your system's clock, reference time and timezone, like:

Local time: Wed 2021-06-16 15:04:41 -03   
Universal time: Wed 2021-06-16 18:04:41 UTC   
RTC time: Wed 2021-06-16 18:04:41       
Time zone: America/Fortaleza (-03, -0300)
System clock synchronized: yes 
Enter fullscreen mode Exit fullscreen mode

(Remember, if you feel lost during this walk-through, just run timedatectl --help to get more information on how to correctly change your system's timezone!)

Now that you already know your current timezone, it's time to run:
$ timedatectl list-timezones
to check the exact name for your new timezone. For the purposes of this tutorial, let's stick to Europe/Oslo. We just need to find it in the list (which is quite extensive!) and copy it. If you already know the exact name of the timezone you gotta change your system to, you can just skip to the next step.

Now, run:
$ timedatectl set-timezone Europe/Oslo
and it'll change the timezone instantly.
Run again:
$ timedatectl
and your output should be more or less like this:

Local time: Wed 2021-06-16 20:16:59 CEST
Universal time: Wed 2021-06-16 18:16:59 UTC 
RTC time: Wed 2021-06-16 18:16:59     
Time zone: Europe/Oslo (CEST, +0200)   
System clock synchronized: yes                         
NTP service: active                      
RTC in local TZ: no  
Enter fullscreen mode Exit fullscreen mode

Discussion (0)