Change the Timezone in Linux

How to Change the Timezone in Linux

Using the Graphical User InterfaceUsing the Timezone Selection MenuUsing the Command Line

Whether you’re a new user or a seasoned terminal expert, you can easily change the timezone of your Linux computer. There are three main ways to change the timezone settings in Linux; one uses the desktop and the other two are executed through the command line. Follow this guide to learn all of them.

EditMethod 1 of 3: Using the Graphical User Interface

  1. Click on the System menu and select Administration. Select the Time and Date option.
    • Alternatively, you can click on the clock and select Time and Date settings from the menu.
    • This method is for Ubuntu. The menu options are similar for most Linux distributions.[1]

  2. Click your currently selected timezone. Depending on your distribution, you may have to select a timezone tab first.
  3. Select your location on the world map. Most everyu distribution will have a graphic map that you can use to select your location. This will help narrow down the correct timezone for you.
    • After selecting your general location, select the closest city.

EditMethod 2 of 3: Using the Timezone Selection Menu

  1. Open the terminal. This method will open an ASCII menu that will allow you to choose your timezone. Enter the following command based on the Linux distribution you are using:
    • Ubuntu: dpkg-reconfigure tzdata
    • Redhat: redhat-config-date
    • CentOS/Fedora: system-config-date
    • FreeBSD/Slackware: tzselect
  2. Select your timezone. Each distribution will open a slightly different menu, but all generally perform the same function. Navigate to the region and city that best matches your location and select it. This will change the timezone on your system.[2]

EditMethod 3 of 3: Using the Command Line

  1. Check your current timezone. Log in as root. Open the terminal and check which timezone your machine is currently using by executing the date command. The terminal will display the date in the following format: Mon Aug 12 12:15:08 PST 2013. PST in this case refers to the current timezone (Pacific Standard Time).
  2. Select your timezone region. Change to the directory /usr/share/zoneinfo. A list of time zone regions will be displayed. Choose the most appropriate region by pressing the corresponding number.
    • The /usr/share/zoneinfo directory may vary depending on your Linux distribution.
  3. Backup your old timezone settings. If you wish, backup the previous timezone configuration by renaming it to a backup name. Use the following command mv /etc/localtime /etc/localtime-old
  4. Link your machine’s clock to a city in your timezone. Use the following command, replacing the region and city with your appropriate entries: ln -sf /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime [3]
    • If your city is not listed in the timezone list, pick one from your same timezone.
  5. Verify that your timezone has been set. Run the date command again and check that the timezone corresponds to the one you just changed to.
  6. Set your clock to stay synced with internet time servers. Most modern distributions have NTP already installed. If you do not, you will need to install the NTP server package. Use the following commands to install it, depending on your Linux distribution:
    • Ubuntu/Debian: sudo aptitude install ntp
    • CentOS: sudo yum install ntp
      sudo /sbin/chkconfig ntpd on
    • Fedora/RedHat: sudo yum install ntp
      sudo chkconfig ntpd on
    • Enter the ntpdate command: ntpdate <time server> && hwclock –w
    • There are a variety of public time servers available to connect to. You can find listings online.[4]

Leave a Reply