Setting the timezone under Linux

The objective of this guide is to show how to set the system time zone on Linux. This can be done from both GUI and command line, so we’ll be covering both methods in the following instructions.

Setting your system time and time zone is usually done when initially installing Linux. If you skipped that step during installation, have switched time zones, or your system clock has drifted out of sync, we’ll help you get it fixed.

In this tutorial you will learn:

  • How to set time zone via command line (systemd)
  • How to set time zone via GNOME GUI
  • How to set time zone via KDE GUI

Setting the time zone on Linux

Setting the time zone on Linux

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software N/A
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Set time zone via GNOME GUI



This section of the guide will cover setting your time zone on the GNOME desktop environment. Follow the step by step instructions below to get started.

  1. Start by opening the activities menu and searching for “time”. Click the Date and Time settings menu that shows up.
  2. Search for and open the Date and Time menu

    Search for and open the Date and Time menu

  3. Next, select the time zone option.
  4. Select the option to change system time zone

    Select the option to change system time zone

  5. You may pick a location on the map or just type a major city or time zone into the search bar. It should auto complete your search, allowing you to find the proper time zone very quickly.
  6. Pick a time zone from the map or begin typing one for suggestions

    Pick a time zone from the map or begin typing one for suggestions

That’s all there is to it. You can close the Date and Time settings menu after you’re satisfied with the changes.

Set time zone via KDE GUI

This section of the guide will cover setting your time zone on the KDE Plasma desktop environment. Follow the step by step instructions below to get started.

  1. Start by opening the application launcher and searching for “time”. Click the Date and Time settings menu that shows up.


  2. Search for and open the Date and Time menu

    Search for and open the Date and Time menu

  3. Click on the time zone tab and then select your preferred time zone or start typing a major city to find the relevant one.
  4. Choose a time zone from the list or begin typing one for suggestions

    Choose a time zone from the list or begin typing one for suggestions

That’s all there is to it. You can close the Date and Time settings menu after you’re satisfied with the changes.

Set time zone via command line

Setting a Linux system’s date, time, and time zone can also be done from the command line, as we’ll see below. We’re assuming that you’re running a distro with systemd, which there’s an extremely high chance that you are.

  1. The first thing to decide is whether you want time synchronization on or off. If you plan to set the date and time manually, time synchronization will need to be turned off, otherwise your changes will be quickly overridden by the system. Turn time synchronization on or off, respectively, with the commands below.
    # timedatectl set-ntp on
    OR
    # timedatectl set-ntp off
    
  2. If you’d like to set the system clock to some arbitrary date and time, ensure that time synchronization is off (as we’ve shown above) and use the following date command. This command will set the date and time to 10 January 2021, 12:00 PM, but substitute any values you want.
    # date -s "10 JAN 2021 12:00:00"
    


  3. If you decide to keep time synchronization on, then you just need to configure the system’s time zone in order to have it automatically pull the correct data from a time server. Type the following command to see what time zone your system is currently configured for.
    $ timedatectl
                   Local time: Fri 2021-01-08 04:33:12 EST  
               Universal time: Fri 2021-01-08 09:33:12 UTC  
                     RTC time: Fri 2021-01-08 09:33:11      
                    Time zone: America/New_York (EST, -0500)
    System clock synchronized: no                           
                  NTP service: n/a                          
              RTC in local TZ: no
    
  4. List available time zones with the following command. Pick one relevant to your location, and we’ll configure your system to that time zone in the next step.
    $ timedatectl list-timezones
    

    Use the grep command to narrow down the search. In the example below this command will produce a list of all available time zones in Australia:

    $ timedatectl list-timezones | grep Australia
    Australia/Adelaide
    Australia/Brisbane
    Australia/Broken_Hill
    Australia/Currie
    Australia/Darwin
    Australia/Eucla
    Australia/Hobart
    Australia/Lindeman
    Australia/Lord_Howe
    Australia/Melbourne
    Australia/Perth
    Australia/Sydney
    
  5. Once you’ve picked the correct time zone from the list, use the following syntax to set your system’s time zone.
    # timedatectl set-timezone Australia/Sydney
    


  6. Confirm that the changes have been made with the timedatectl command.
    $ timedatectl
                   Local time: Sat 2021-01-09 14:15:11 AEDT  
               Universal time: Sat 2021-01-09 03:15:11 UTC   
                     RTC time: Fri 2021-01-08 09:46:05       
                    Time zone: Australia/Sydney (AEDT, +1100)
    System clock synchronized: no                            
                  NTP service: n/a                           
              RTC in local TZ: no
    

Closing Thoughts

In this guide, we saw how to set the system date, time, and time zone via GNOME, KDE, and command line on Linux. Not only can you synchronize your clock to any of the world’s time zones, but Linux also allows us to set arbitrary values if we want.



Comments and Discussions
Linux Forum