11.1 Adjust System Time
For many services and proccesses a security check is the diffrence in time settings, this is why Red Hat Linux has an advanced system for time management.
Checking time settings
Check the time settings with the timedatectl command:
[root@rhcsa ~]# timedatectl
Local time: Wed 2020-07-29 05:56:51 EDT
Universal time: Wed 2020-07-29 09:56:51 UTC
RTC time: Wed 2020-07-29 09:56:51
Time zone: America/New_York (EDT, -0400)
System clock synchronized: no
NTP service: inactive
RTC in local TZ: no
The more important settings here other then knowing the time of the VM.
Time zone: America/New_York (EDT, -0400)
System clock synchronized: no
NTP service: inactive
These settings tell you the time zone the vm is in, if the clock is syncronized and wether Network Time Protocol or NTP is turned on.
Turning on NTP
First we must make sure that chrony, this is the ntp protocol server is installed.
dnf install chrony
Now we must check wether the service is on:
systemctl status chronyd
If the status of chronyd is dead/inactive use the following command to turn it on and enable it:
systemctl enable --now chronyd
To turn on the NTP in the timedatectl command:
timedatectl set-ntp true
Result can be checked with timedatectl
[root@rhcsa ~]# timedatectl
Local time: Wed 2020-07-29 06:00:39 EDT
Universal time: Wed 2020-07-29 10:00:39 UTC
RTC time: Wed 2020-07-29 10:00:40
Time zone: America/New_York (EDT, -0400)
System clock synchronized: no
NTP service: active
RTC in local TZ: no
Now it is turned on but the clock is not yet syncronized this might take some time to check that.
chronyc sources -v
[root@rhcsa ~]# chronyc sources -v
210 Number of sources = 4
.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| / '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | | \
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^- ntp18.kashra-server.com 2 6 73 34 +5209us[+5209us] +/- 24ms
^* time.cloudflare.com 3 6 37 37 -6253ns[ -416us] +/- 3347us
^- mail.picquenot.com 2 6 37 37 -3751us[-4160us] +/- 32ms
^- reinhardt.pointpro.nl 2 6 37 36 -276us[ -276us] +/- 34ms
Now we need to make sure our VM is talking to our local NTP server:
[root@rhcsa ~]# vim /etc/chrony.conf
Remove the lines with server pool X.centos.pool.org and add:
server 192.168.56.100 iburst
The top of the file looks like this:
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 192.168.56.100 iburst
#pool 2.centos.pool.ntp.org iburst
Restart the chronyd service:
systemctl restart chronyd
Check if your ntp is syncing with our server:
chronyc sources -v
[root@rhcsa ~]# chronyc sources -v
210 Number of sources = 1
.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| / '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | | \
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^? 192.168.56.100 0 7 0 - +0ns[ +0ns] +/- 0ns
Changing Time Zones
We now know how to check our time with the local NTP server but we also want to change the time zone, first check the curent timezone.
timedatectl
You’ll see: Time zone: America/New_York (EDT, -0400)
Lets list all the timezones to see if we can find the one we want:
timedatectl list-timezones
A very very long list will apear you can scroll through the list until you find Amsterdam or we can use a slightly quicker version with grep.
timedatectl list-timezones |grep Amsterdam
Notice that the word Amsterdam is case sensitive.
Change the timezone to Europe/Amsterdam, and you can verify the results with the timedatectl command.
[root@rhcsa ~]# timedatectl set-timezone Europe/Amsterdam