Time zones are important settings on any operating system, as they ensure that the system clock displays the correct local time. Debian Linux, a popular and widely-used Linux distribution, provides an easy-to-use command-line tool to change the time zone. This article will guide you through the process of changing the time zone on your Debian system using the ‘timedatectl’ command and the ‘tzdata’ package.

Advertisement

Check Current Timezone

You can view the current time zone of a system by simply typing the ‘date’ command in the terminal.

date 
Output:
Sat 26 Mar 2022 05:43:11 AM UTC

The above command shows that this system is running in the UTC timezone.

You can also refer to the timedatectl command to view the details output of the current system time, timezone, and many other details.

timedatectl 
Output:
Local time: Sat 2022-03-26 05:43:49 UTC Universal time: Sat 2022-03-26 05:43:49 UTC RTC time: Sat 2022-03-26 05:43:48 Time zone: Etc/UTC (UTC, +0000) System clock synchronized: no NTP service: n/a RTC in local TZ: no

Set or Change Time Zone in Linux

Linux keeps time zone relegated files available under /usr/share/zoneinfo directory. There you can find all the available time zone.

You can choose one of the below methods to change the Linux system time zone via the command line.

  • Method 1 – Using timedatectl command (Recommended)

    Use of timedatectl command is the proffered way to set or change the time zone on a Linux system. You can list all the available time zones with the following command.

    timedatectl list-timezones 
    

    Find out the correct time zone for your system in the above result. Next, use the following command to set a new time zone to the Linux system.

    sudo timedatectl set-timezone "America/Los_Angeles" 
    
  • Method 2 – Using /etc/localtime

    You can also change the system time by changing the symbolic link of /etc/localtime file on Linux systems. You just need to search for the correct time zone files under /usr/share/zoneinfo directory.

    First rename or remove the current file:

    sudo mv /etc/localtime /etc/localtime-old
    

    Then change the symbolic link of file to the correct time zone configuration file:

    sudo ln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime 
    
  • The system will automatically adjust the new time based on the new time zone set on the system. You can again run “timedatectl” command to confirm the time zone is updated correctly.

Verify the changes

To ensure that the time zone has been updated correctly, check the current date and time using the ‘date’ command:

date 

Conclusion

Changing the time zone on a Debian Linux system can be easily accomplished using the ‘timedatectl’ command or the ‘tzdata’ package. Both methods provide a simple way to update your system’s time zone, ensuring that your system clock displays the correct local time.

Share.

1 Comment

Leave A Reply


Exit mobile version