In this example we are going to set server encoding, locale, timezone and NTP server so that all in line with the country we are in. I am in UK!


Setup


$ apt-get update -y

language and encoding


$ sed -i "s/# en_GB.UTF-8 UTF-8/en_GB.UTF-8 UTF-8/g" /etc/locale.gen
$ locale-gen en_GB.UTF-8
$ update-locale LANG=en_GB.UTF-8
$ update-locale LC_ALL=en_GB.UTF-8
$ update-locale LANGUAGE=en_GB:en
$ update-locale

timezone


$ timedatectl set-timezone Europe/London

ntp


# Instal
$ apt-get install -y ntp

# Configure
cat > /etc/ntp.conf <driftfile /var/lib/ntp/ntp.drift

server 0.uk.pool.ntp.org iburst
server 1.uk.pool.ntp.org iburst
server 2.uk.pool.ntp.org iburst
server 3.uk.pool.ntp.org iburst

restrict 127.0.0.1
restrict ::1
EOF

# Correct the time (Not needed for Ubuntu)
service ntp stop
ntpd -gq
service ntp start

# Enable startup
systemctl enable ntp

# Synchronize the system clock (Not needed for Ubuntu)
$ timedatectl set-ntp true

If you need to restart ntp run $ systemctl restart ntp command.


Status


Debian


$ timedatectl
Local time: Sun 2018-05-27 10:35:00 BST
Universal time: Sun 2018-05-27 09:35:00 UTC
RTC time: Sun 2018-05-27 09:34:59
Time zone: Europe/London (BST, +0100)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: yes
Last DST change: DST began at
Sun 2018-03-25 00:59:59 GMT
Sun 2018-03-25 02:00:00 BST
Next DST change: DST ends (the clock jumps one hour backwards) at
Sun 2018-10-28 01:59:59 BST
Sun 2018-10-28 01:00:00 GMT

$ locale
LANG=en_GB.UTF-8
LANGUAGE=en_GB:en
...
LC_ALL=en_GB.UTF-8

Ubuntu


$ timedatectl
Local time: Sun 2018-05-27 10:35:00 GMT
Universal time: Sun 2018-05-27 10:35:00 UTC
RTC time: Sun 2018-05-27 10:35:00
Time zone: Europe/London (GMT, +0000)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no

$ locale
LANG=en_GB.UTF-8
LANGUAGE=en_GB:en
...
LC_ALL=en_GB.UTF-8