🖥️ntp

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the ntp command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███╗   ██╗████████╗██████╗ 
#                ████╗  ██║╚══██╔══╝██╔══██╗
#                ██╔██╗ ██║   ██║   ██████╔╝
#                ██║╚██╗██║   ██║   ██╔═══╝ 
#                ██║ ╚████║   ██║   ██║     
#                ╚═╝  ╚═══╝   ╚═╝   ╚═╝     
                

                                          
# alias für offset:
alias ntpsync='service ntp stop ; ntpd -g -q ; service ntp start'

# Verify ntpd running:
service ntp status

# Start ntpd if not running:
service ntp start

# Display current hardware clock value:
sudo hwclock -r

# Apply system time to hardware time:
sudo hwclock --systohc

# Apply hardware time to system time:
sudo hwclock --hctosys

# Set hwclock to local time:
sudo hwclock --localtime

# Set hwclock to UTC:
sudo hwclock --utc

# Set hwclock manually:
sudo hwclock --set --date="8/10/15 13:10:05"

# Query surrounding stratum time servers
ntpq -pn

# Config file:
/etc/ntp.conf

# Driftfile:
location of "drift" of your system clock compared to ntp servers /var/lib/ntp/ntp.drift

#-------------------------------------------------#

# Vorgehensweise bei ntp offset
#--------------------------------#

service ntp stop
ntpd -g -q			
# Die Option -g bedeutet, dass ntpd auch synchronisiert, wenn die Zeit mehr als 1000 Sekunden abweicht. Die Option -q bedeutet, dass ntpd nur einmal ausgeführt wird.
service ntp start

hwclock --systohc
# die Uhr in die Hardwareclock schreiben, denn sonst kommt der Server eventuell nach einem Boot mit einer völlig falschen Zeit hoch.

# Verify ntpd running:
service ntp status

# Start ntpd if not running:
service ntp start

# Display current hardware clock value:
sudo hwclock -r

# Apply system time to hardware time:
sudo hwclock --systohc

# Apply hardware time to system time:
sudo hwclock --hctosys

# Set hwclock to local time:
sudo hwclock --localtime

# Set hwclock to UTC:
sudo hwclock --utc

# Set hwclock manually:
sudo hwclock --set --date="8/10/15 13:10:05"

# Query surrounding stratum time servers
ntpq -pn

# Config file:
/etc/ntp.conf

# Driftfile:
location of "drift" of your system clock compared to ntp servers
/var/lib/ntp/ntp.drift

# example config
tinker panic 0
server ntptime.lxu.io burst iburst
driftfile /var/lib/ntp/drift/ntp.drift
logfile /var/log/ntp

##############################################

# BASH script to synchronize with NTP server - This is a simple script (can be safely placed in a cron) to sync your machine with the default NTP server            
##############
service ntpd stop
ntpdate 156.54.18.6  // replace 156.54.18.6 with correct server IP address
ntpdate 156.54.18.6
ntpdate 156.54.18.6
ntpdate 156.54.18.6
service ntpd start
chkconfig ntpd on
##############

#==============================##==============================#
# CMD NTP						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░