# epoch seconds> date +%s 1786188795# epoch milliseconds> date +%s%3N1786188872644# epoch nanoseconds> date +%s%N1786188884030439201
System clock uses following hardware under the hood
Timestamp counter (TSC)
It is CPU register
The TSC counts every single electrical cycle the CPU core executes
High Precision Event Timer (HPET)
It is a chip on motherboard
Ticks at an un-shifting, constant frequency
If the Linux kernel detects that your CPU cores are changing speeds dynamically due to heat or power-saving adjustments, The kernel will start using HPET
Clock drifting
If the clocks drift from network time, NTP resolves it using two methods:
Stepping
Instantly alters the system clock to match the correct time exactly
It breaks the monotonicity of time
It can cause crashes of databases, application logs etc.
Happens if time error > 128 ms
Slewing
Gradually adjusts the system clock rate until it matches the correct time without making any instant leaps
Time flows smoothly and never moves backward
# use date command for quick modificationsdate# modern command to manage global date time# show date, time, timezone, NTP service status, RTC timetimedatectl
Timezone
Timezone related files
/usr/share/zoneinfo/
Pre-compiled binary rule files for every geographic region on Earth
/etc/localtime
System default timezone
Symlink to one of the timezone in /usr/share/zoneinfo/
Example symlink to /usr/share/zoneinfo/Asia/Kolkata
# list timezonestimedatectl list-timezones# see current timezonedate +"%Z %z"timedatectl
Locale
locale command lists different settings for locale
LANG is default global blueprint
LC_* are specific categories
LC_ALL forcibly overwrites all categories
LANGUAGE defines a colon-separated list of fallback languages
To evaluate config for a category
LC_ALL (if set) —> LC_* (if set) —> LANG
For text translations (language, not locale)
LANGUAGE (if set, try for all fallbacks) —> LC_ALL —> LC_* —> LANG
Locale related files
/usr/share/i18n/locales/ (Source text files)
Human readable data
/usr/lib/locale/locale-archive (Binary database)
Single optimized binary used by programs
# current locale settings> localeLANG=en_INLANGUAGE=en_IN:enLC_CTYPE="en_IN"LC_NUMERIC="en_IN"LC_TIME="en_IN"LC_COLLATE="en_IN"LC_MONETARY="en_IN"LC_MESSAGES="en_IN"LC_PAPER="en_IN"LC_NAME="en_IN"LC_ADDRESS="en_IN"LC_TELEPHONE="en_IN"LC_MEASUREMENT="en_IN"LC_IDENTIFICATION="en_IN"LC_ALL=# list available locales> locale -aCC.utf8en_INen_IN.utf8POSIX# list available char maps (character sets)> locale -m# See raw formatting strings queried from locale database> locale LC_TELEPHONE+%c ;%a ;%l0091UTF-8