In this article, we will show you how to change the time zone and language of our server.
Change the time zone with a symbolic link
The easiest way to change the time zone is to change the symbolic link at /etc/localtime. Simply change the link to /usr/share/zoneinfo/MiContinente/MiCiudad.
For example, to change the time zone to Madrid, we will run:
ln -sfn /usr/share/zoneinfo/Europe/Madrid /etc/localtimeChange the time zone with timedatectl
Some Linux distributions have the timedatectl command available. This command lets us view a lot of information; running it will return a result like this:
timedatectl Local time: mié 2019-08-28 13:43:15 CEST
Universal time: mié 2019-08-28 11:43:15 UTC
RTC time: mié 2019-08-28 11:43:16
Time zone: Europe/Brussels (CEST, +0200)
System clock synchronized: yes
systemd-timesyncd.service active: yes
RTC in local TZ: no
We can quickly see the universal time (UTC), our time zone, and whether the server automatically synchronizes our server's time.
We can also view a list of time zones:
timedatectl list-timezonesOr change our time zone:
timedatectl set-timezone Europe/MadridChange the language
Some Linux distributions have the localectl command available. Run it to view the locale settings shown below. You can view the available languages with localectl list-locales:
System Locale: LANG=en_US.UTF-8
VC Keymap: n/a
X11 Layout: es
X11 Model: pc105
X11 Variant: cat
Podemos ver los idiomas disponibles con:
localectl list-locales
We can add languages with:
locale-gen es_ES.utf8Now that we have generated the language, we can configure it with:
localectl set-locale LANG=es_ES.utf8Once our server has restarted, it will be in Spanish.
Ubuntu/Debian-specific commands
On Ubuntu/Debian servers, we can also run “dpkg-reconfigure tzdata” to configure the time zone or “dpkg-reconfigure locales” to configure the server's language. The time zone changes immediately; changing the language requires us to restart our server.