Time Management

Maintaining Time in Linux

It is important to understand how to configure your time zone and maintain the time in Linux. We do not want to have the system time skew as this can cause issues with installing or maintaining the system. Also, if the system time is not correct log entries will have the wrong time and make determine when something happened very tricky/challenging. We will look at how to configure our time zone and maintain our system time. We will also look at what the locale is in Linux.  The locale is what defines your language, country and any other special preference you wish to see in your UI. The Locale usually has a region and language identifier.

Change/Set Time  zone 

At times you might have to update the time zone configuration in Linux. This can be done in multiple ways, so please make sure to watch the video provided and read the articles below. Having the wrong time zone could cause issues with Linux not displaying the correct time.

https://linux.die.net/man/8/tzselect

https://acloudguru.com/blog/engineering/changing-the-time-zone-in-linux-command-line

https://www.linuxtechtips.com/2013/12/change-timezone-in-linux-in-different.html

Even though the video shows Kali Linux it is based on Debian, just like MX Linux. The commands/process will be the same.

locale

The locale are environmental variables that define the country, language and character encoding that Linux will us. This is important it could affect how your date and time are displayed. In the US we are use to having our calendar show as Month/Day/Year, but in some countries it is displayed as Day/Month/Year. The locale can influence how even your calendar is displayed in Linux. Also, system libraries will use the locale information as well. 

https://linux.die.net/man/1/locale

https://www.tecmint.com/set-system-locales-in-linux/

date

The date command can be used for a lot of different uses. A majority of the time I only find myself using it to get current date and time information. You can use the date command to output the date in a format you specify or even figure out what a date will be in the future (such as saying next Friday). 

https://linux.die.net/man/1/date

https://vitux.com/linux-date-command-example/

https://www.thegeekstuff.com/2013/05/date-command-examples/

ntpdate

NTP (Network Time Protocol) is not just for Linux, but it is also used in Windows and MacOS. NTP provides a method to update/maintain your system time using a server. This can help avoid time skew on your Linux system. 

https://linux.die.net/man/8/ntpdate

http://www.ntp.org/ntpfaq/NTP-s-def.htm#AEN1284

https://en.wikipedia.org/wiki/Network_Time_Protocol


Why is this important?

We need to make sure that all our Linux systems have a correct time stamp on log files.  Also, if you are running Linux on a server or as a virtual machine on a server you might be sending your log data to a syslog server. A syslog server collects and mataintains log files from various systems. You need your time to be correct for when an event happens. If your systems all have different times it'd be nearly impossible to determine when an event took place.