To change or set up the time zone on a Linux server, follow these steps:
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'.
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
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'
timedatectl
command. This command allows you to set the time and time zone for the system.$ timedatectl set-timezone time_zone
$ 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.