Changing your timezone in Linux

If you manage any servers you will know that matching timezones and system is crucial for several reasons. This script is designed to speed up your work.

Changing your timezone in Linux

If you manage any servers you will know that matching timezones and system is crucial for several reasons. Error messages and logs are much more helpful. However if you have services that are time based (such as 2FA/MFA) then they are essential and those systems will fail without matched times from devices and networks.

I often got error messages on applications using 2FA/MFA which ended up being time issues. I would often get errors on apps and using my Yubikey. So this script was my attempt to edit the system time and timezone of my servers through a unified script. Making the process a little quicker.

What does the script do?
Here is a step by step of the script:

  1. Check if the script is being run with root (sudo) privileges to update the system time and timezone.
  2. Display the current system time and timezone using the date and timedatectl commands.
  3. Prompt the user if they want to update the system time and timezone.
  4. If the user chooses to update, the script will prompt for the new timezone.
  5. Set the new timezone using the timedatectl set-timezone command.
  6. Display the updated system time and timezone.
  7. Provide a success message.

How To & Download

  • Download the file from GitHub or save the script to a file (e.g., update_time_and_timezone.sh), make it executable:
  • chmod +x update_time_and_timezone.sh
  • Run it with sudo privileges to update your system's time and timezone.
GitHub - FaithlessTheory/timezone-script: Script for checking and altering Timezone in Linux
Script for checking and altering Timezone in Linux - GitHub - FaithlessTheory/timezone-script: Script for checking and altering Timezone in Linux