System Date

Linux distros often come with a wonky system date--both in the past (i.e., when the image was generated) and in a different timezone (usually GMT). This can cause significant issues on web servers, as signed SSL certificates are only valid within a date range.

Set the timezone before trying to set the date.


Timezone

The easy-to-use tool for setting timezones is timedatectl.

timedatectl status                      # observe current setting
timedatectl list-timezones              # observe available settings
timedatectl set-timezone Zone/SubZone   # apply a new setting

This is just a wrapper around ln however. The manual process is:

realpath /etc/localtime                                  # observe current setting
ls /usr/share/zoneinfo                                   # observe available zones
ls /usr/share/zoneinfo/Zone                              # observe available subzones
ln -sf /usr/share/zoneinfo/Zone/SubZone /etc/localtime   # apply a new setting


Date

The system date is set using the standard date utility, run as the superuser with an argument.

sudo date 2001011230   # sets system date to January 1st, 2020 at 12:30


CategoryRicottone