System Clock in Linux

The system clock in Linux generally uses the Coordinated Universal Time (UTC) standard, as opposed to localtime.

Linux images often come with a wonky clock setting based on when the image was generated. This can cause significant issues on web servers, as signed SSL certificates are only valid within a date range.


Timezone

For systemd-capable systems, use timedatectl(1) to set the local timezone. Substitute America/New_York with your preferred configuration.

timedatectl status
timedatectl list-timezones
timedatectl set-timezone America/New_York

timedatectl(1) is a simple utility script; the manual equivalents roughly are...

realpath /etc/localtime
ls /usr/share/zoneinfo/*
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime

Some utilities will also respect a TZ environment variable.

export TZ=America/New_York
date


Date and Time

Use date(1) to set the current datetime. Note that date(1) must be called by the root user to set a datetime.

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


CategoryRicottone