HowTo: Linux Server Change OR Setup The Timezone

http‮‬s://www.lautturi.com
HowTo: Linux Server Change OR Setup The Timezone

To change or set up the time zone on a Linux server, follow these steps:

  1. Identify the time zone you want to use. You can find a list of valid time zones in the /usr/share/zoneinfo directory on most systems. The time zone is typically specified in the format 'Continent/City', such as 'America/New_York' or 'Europe/Paris'.

  2. Use the tzselect command to interactively select the desired time zone. This command will guide you through a series of prompts to select the appropriate region and city, and will output the appropriate value for the TZ environment variable.

$ tzselect
  1. Set the TZ environment variable to the desired time zone. You can set this variable globally by editing the /etc/timezone file and adding the time zone as a single line of text. Alternatively, you can set the TZ variable for a specific user by adding the following line to the user's shell configuration file, such as .bashrc or .bash_profile, depending on the shell being used:
export TZ='time_zone'
  1. Update the system clock to the correct time using the timedatectl command. This command allows you to set the time and time zone for the system.
$ timedatectl set-timezone time_zone
  1. Restart any services that rely on the system clock, such as the SSH server or the web server, to apply the changes.
$ systemctl restart ssh
$ systemctl restart apache2

Keep in mind that these steps will only set the time zone for the current system. If you are using a network time protocol (NTP) server to synchronize the system clock with a remote time source, you may need to adjust the NTP configuration as well.

Created Time:2017-10-29 22:08:44  Author:lautturi