\errorcontextlines=99 %% Subtopic Number = '1.111.6' %% Title from filename: 'Maintain system time' %% Weight: 4 %% Description: %% Candidate should be able to properly maintain the system %% time and synchronize the clock over NTP. Tasks include setting the %% system date and time, setting the BIOS clock to the correct time in UTC, %% configuring the correct timezone for the system and configuring the %% system to correct clock drift to match NTP clock. %% Key files, terms, and utilities include: %% /usr/share/zoneinfo %% /etc/timezone %% /etc/localtime %% /etc/ntp.conf %% /etc/ntp.drift %% date %% hwclock %% ntpd %% ntpdate \documentclass[10pt,a5paper]{article}% DO NOT EDIT---WILL BE OVERWRITTEN \usepackage{beamerarticle,geometry,graphicx}% DO NOT EDIT---WILL BE OVERWRITTEN \geometry{margin=10mm,includehead,headheight=15pt,headsep=5mm}% DO NOT EDIT---WILL BE OVERWRITTEN \usepackage{fancyhdr}% DO NOT EDIT---WILL BE OVERWRITTEN \usepackage[breaklinks]{hyperref}% DO NOT EDIT---WILL BE OVERWRITTEN \title{1.111.6\\Maintain system time\\Weight 4} \author[Geoff Robertson]{Geoffrey Robertson \texttt{ge@ffrey.com} \and Nick Urbanik \texttt{nicku@nicku.org}} \subtitle{Linux Professional Institute Certification --- 102} \mode { %\usetheme{Warsaw} \usetheme[hideothersubsections]{Goettingen} % or ... \setbeamercovered{transparent=80} % or whatever (possibly just delete it) \subject{LPIC 102} } \mode
{ \usepackage{url} \renewcommand{\floatpagefraction}{0.75} % default is .5, to increase % density. \renewcommand*{\bottomfraction}{0.6} % default is 0.3 \renewcommand*{\topfraction}{0.85} % default is 0.7 \renewcommand*{\textfraction}{0.1} % default is 0.2 \pagestyle{fancy} \fancyhf{} \renewcommand{\sectionmark}[1]{\markright{\thesection. #1}} \lhead{\nouppercase{\rightmark}} \rhead{\thepage} } \usepackage[english]{babel} \usepackage{alltt,booktabs,array,cols,multicol,meta,acro} \usepackage[utf8]{inputenc} % or whatever \usepackage{times} \usepackage[T1]{fontenc} % Or whatever. Note that the encoding and the font should match. If T1 % does not look nice, try deleting the line with the fontenc. \usepackage{xcolour-names} \title{Reconfigure, build, and install a custom kernel and kernel} \subtitle{Subtopic Number: 1.105.2\\LPIC 102} \author[Nick Urbanik]{Nick Urbanik \texttt{\footnotesize{}nicku@nicku.org}\\ {\tiny This document Licensed under GPL---see slide~\pageref{sld:license}}% } \date{2005 September} % Copyright (C) 2005 Nick Urbanik % You can redistribute modified or unmodified copies of this document % provided that this copyright notice and this permission notice are % preserved on all copies under the terms of the GNU General Public % License as published by the Free Software Foundation--either version 2 % of the License or (at your option) any later version. \AtBeginSubsection[] { \begin{frame} \frametitle{Outline} \footnotesize \begin{multicols}{2} \tableofcontents[currentsection,currentsubsection] \end{multicols} \end{frame} } % If you wish to uncover everything in a step-wise fashion, uncomment % the following command: %\beamerdefaultoverlayspecification{<+->} \newcounter{program} %\newcommand*{\program}[1]{\refstepcounter{program}\label{#1}\arabic{program}} % \newcommand*{\program}[1]{% % \refstepcounter{program}\hypertarget{#1}{Program \texttt{#1}}% % } %\newcommand*{\program}[1]{\refstepcounter{program}\label{#1}\arabic{program}} \newcommand*{\program}[1]{% \hypertarget{#1}{Program \texttt{#1}}% } \newcommand*{\linkto}[1]{\hyperlink{#1}{\texttt{#1}}} \providecommand*{\bs}{\texttt{\char '134}} % Backslash, no break \newcommand{\cmd}[1]{% \texttt{\$ \textbf{#1 \(\hookleftarrow\)}} } \newcommand{\rootcmd}[1]{% \texttt{\# \textbf{#1 \(\hookleftarrow\)}} } \newcommand{\opt}[1]{% {\bfseries\texttt{#1}} } \begin{document} \begin{frame} \titlepage \end{frame} \begin{frame} \frametitle{Outline} \mode {% \footnotesize \begin{multicols}{2} \tableofcontents \end{multicols} % You might wish to add the option [pausesections] }% \mode
{% \tableofcontents }% \end{frame} \begin{frame} \frametitle{Description of Objective} \framesubtitle{1.111.6\ \ Maintain system time} \Large{}Candidate should be able to properly maintain the system time and synchronize the clock over NTP. Tasks include: \begin{itemize} \item setting the system date and time, \item setting the BIOS clock to the correct time in UTC, \item configuring the correct timezone for the system and \item configuring the system to correct clock drift to match NTP clock. \end{itemize} \end{frame} \begin{frame}[fragile] %% GENERATED SLIDE \frametitle{Key files, terms, and utilities include:} \begin{semiverbatim}\large /usr/share/zoneinfo /etc/timezone /etc/localtime /etc/ntp.conf /etc/ntp.drift date hwclock ntpd ntpdate \end{semiverbatim} \end{frame} %----10->|-----20->|-----30->|-----40->|-----50->|-----60->|-----70->|-----80-> %============================================================================== % \begin{frame}[fragile] % %ghr % \listofslides % \end{frame} %------------------------------------------------------------------------------ %============================================================================== %============================================================================== % \begin{frame}%[fragile] % %ghr % \frametitle{(2.2) Administrative Tasks [21]} % \begin{description} % \item[2.111.1] Manage users and group accounts and related system files [4] % \item[2.111.2] Tune the user environment and system environment variables [3] % \item[2.111.3] Configure and use system log files to meet % administrative and security needs [3] % \item[2.111.4] Automate system administration tasks by scheduling % jobs to run in the future [4] % \item[2.111.5] Maintain an effective data backup strategy [3] % \item[2.111.6] {\bf \underline{Maintain system time [4]}} % \end{description} % \end{frame} %----------------------------------------------------------- %============================================================================== %============================================================================== % \begin{frame}%[fragile] % %ghr % \frametitle{Maintain system time [4]} % \framesubtitle{Objective} % Candidate should be able to properly maintain the system time and % synchronise the clock over NTP. % Tasks include: % \begin{itemize} % \item Setting the system date and time % \item Setting the BIOS clock to the correct time in UTC % \item Configuring the correct timezone for the system % \item Configuring the system to correct clock drift to match NTP % clock. % \end{itemize} % \end{frame} %----------------------------------------------------------- % %============================================================================== % \begin{frame}[fragile] % %ghr % \frametitle{Maintain system time [4]} % \framesubtitle{Key files, terms, and utilities} % \begin{semiverbatim} % date % hwclock % ntpd % ntpdate % /usr/share/zoneinfo % /etc/timezone % /etc/localtime % /etc/ntp.conf % /etc/ntp.drift % \end{semiverbatim} % \end{frame} %----------------------------------------------------------- %============================================================================== \begin{frame}[fragile] \frametitle{Maintain system time [4]} \framesubtitle{Resources of interest} \begin{description} \item[web] \texttt{http://www.ntp.org} \item[Debian ntp-doc] \texttt{/usr/share/doc/ntp-doc/index.html} on sarg. \item[LPI Linux Certification in a Nutshell:] \texttt{by Jeffrey Dean}\\ \textsf{O'Reilly} \item[LPIC 1 Certification Bible:] \textit{Angie Nash and Jason Nash}\\ \textsf{Hungry Minds} \end{description} \end{frame} %============================================================================== %============================================================================== \begin{frame}[fragile] %Andrew Eager \frametitle{\texttt{date}} \framesubtitle{Display or Set System Date \& Time} The date command without any options will print the current date and time. The date will be relative to any timezone set for the machine. \begin{semiverbatim} \cmd{date} Tue May 21 09:57:51 EST 2002 \end{semiverbatim} \end{frame} %----------------------------------------------------------- %============================================================================== \begin{frame}[fragile] %Andrew Eager \frametitle{\texttt{date}} \framesubtitle{Options to the Date command} \begin{description} \item[\opt{-I}] Output an ISO-8601 compliant date (YYYY-MM-DD) \begin{semiverbatim} \cmd{date -I} 2002-05-21 \end{semiverbatim} %\overlay{1} \item[\opt{-R}] Output an RFC-822 compliant date (Local time + GMT 0ffset) \begin{semiverbatim} \cmd{date -R} Tue, 21 May 2002 10:14:09 +1000 \end{semiverbatim} %\overlay{2} \item[\opt{-r $<$file\textgreater}] Display the last modification time of file \begin{semiverbatim} \cmd{date -r ~/ivr/va/src/va.c} Mon May 20 12:55:48 EST 2002 \end{semiverbatim} \end{description} \end{frame} %----------------------------------------------------------- %============================================================================== \begin{frame}[fragile] %Andrew Eager \frametitle{\texttt{date}} \framesubtitle{Options to the Date command} \begin{description} \item[\texttt{-d \textless STRING\textgreater}] Display date described by string instead of now \begin{alltt} \cmd{date -d "last Monday 4 years ago"} Mon May 18 00:00:00 EST 1998 \end{alltt} %\overlay{1} \item[\opt{-u}] Display UTC time \& date instead of localtime \begin{alltt} \cmd{date} Tue May 21 10:55:34 EST 2002 \cmd{date -u} Tue May 21 00:55:34 UTC 2002 \end{alltt} \end{description} \end{frame} %----------------------------------------------------------- %============================================================================== \begin{frame}[fragile] %Andrew Eager \frametitle{\texttt{date}} \framesubtitle{Options to the Date command} \begin{description} \item[\opt{-s \textless date\textgreater}] Set the system time (must be superuser) \begin{semiverbatim} \rootcmd{date -s "Tue May 21 10:03:06 EST 2002"} Tue May 21 10:03:06 EST 2002 \end{semiverbatim} %\overlay{1} \item[\opt{+FORMAT}] Display date in user defined format \begin{semiverbatim} \cmd{date +"Today is %A, %d %B, %Y"} Today is Tuesday, 21 May, 2002 \end{semiverbatim} \end{description} \end{frame} %----------------------------------------------------------- %============================================================================== %============================================================================== \begin{frame}[fragile] %Andrew Eager \frametitle{RTC vs. System Clock} %\overlay{1} \framesubtitle{The \textit{Real Time Clock (RTC)}} This is the hardware clock and is located on the motherboard of the system. This is what keeps track of the time when the system is not powered up. %\overlay{2} \framesubtitle{The \textit{system clock}} This is maintained in the Linux kernel and is used while the system is running. \end{frame} %----------------------------------------------------------- %============================================================================== %============================================================================== \begin{frame}[<+->] %Andrew Eager \frametitle{\texttt{hwclock}} \framesubtitle{RTC vs. System clock} Hwclock is used to do the following: \begin{itemize} \item Set the system clock from the Hardware clock \item Set the hardware clock from the system clock \item Show the time/date held by the RTC \item Adjust the RTC to account for clock drift \end{itemize} \end{frame} %----------------------------------------------------------- %============================================================================== \begin{frame}[<+->] %Andrew Eager %\frametitle{\texttt{hwclock}} \framesubtitle{Set System clock to Hardware clock} \begin{itemize} \item To set the system time from the RTC, use the following option to hwclock: \begin{semiverbatim} hwclock -s (or hwclock --hctosys) \end{semiverbatim} \item To set the RTC from the system time, use this option: \begin{semiverbatim} hwclock -w (or hwclock --systohc) \end{semiverbatim} \item To display the contents of the RTC, use this option: \begin{semiverbatim} hwclock -r (or hwclock --show) \end{semiverbatim} \item To adjust the RTC for clock drift, use this option: \begin{semiverbatim} hwclock -a (or hwclock --adjust) \end{semiverbatim} \end{itemize} Note that the file \texttt{/etc/adjtime} is used to hold information about the extent to which (and direction) your RTC drifts \end{frame} %----------------------------------------------------------- %============================================================================== %============================================================================== \begin{frame}[fragile] %Andrew Eager \frametitle{NTP - Network Time Protocol} %\framesubtitle{\texttt{ntp}} NTP is a time protocol used to synchronise a systems clock to master time source. For example, the CSIRO maintains a nationwide time source with atomic clock accuracy. As a user I can synchronise my system to that time source by sending a request to the CSIRO's ntp server. %%\overlay{1} Features and properties of NTP include: \begin{itemize} %\overlay{2} \item NTP takes into account the time taken to send/receive NTP packets %\overlay{3} \item Uses the UDP protocol %\overlay{4} \item Uses Port 123 plus one other unpriveledged port (1024:65535) %\overlay{5} \item Can operate in both client \& server modes %\overlay{6} \item There are 3 versions of the protocol (ntp1, ntp2 \& ntp3) %\overlay{7} \item Available for Unix \& Windows machines. \end{itemize} \end{frame} %----------------------------------------------------------- %============================================================================== \begin{frame}[fragile] %Andrew Eager \frametitle{NTP - Network Time Protocol} \framesubtitle{The suite of tools} NTP normally comes in a package and contains the following binaries: \begin{itemize} %\overlay{0} \item \texttt{ntpd} - Network Time Protocol (NTP) daemon %\overlay{1} \item \texttt{ntpq} - standard NTP query program %\overlay{2} \item \texttt{ntpdc} - special NTP query program %\overlay{3} \item \texttt{ntpdate} - set the date and time via NTP %\overlay{4} \item \texttt{ntptrace} - trace a chain of NTP servers to the primary source %\overlay{5} \item \texttt{tickadj} - set time-related kernel variables %\overlay{6} \item \texttt{ntptime} - read kernel time variables %\overlay{7} \item \texttt{ntp-genkeys} - generate public and private keys \end{itemize} \end{frame} %----------------------------------------------------------- %============================================================================== \begin{frame}[fragile] %Andrew Eager \frametitle{NTP - Network Time Protocol} \framesubtitle{Quick install guide} For anyone new to NTP, here's a quick guide to installing \& setting up NTP. \begin{itemize} %\overlay{1} \item Install NTP package (\texttt{rpm -Uvh ntp-4.1.0-4.rpm}) \\or\\ \texttt{apt-get install ntp} %\overlay{2} \item Modify \texttt{/etc/ntp.conf} to reflect time servers %\overlay{3} \item Start the service: \texttt{service ntpd start} %\overlay{4} \item Confirm operation using ntpq (command pe) \end{itemize} %\begin{overlay}{5} That's all there is to it! The hardest part is deciding which public time servers to use. %\end{overlay} \end{frame} %----------------------------------------------------------- %============================================================================== \begin{frame}[fragile] %Andrew Eager \frametitle{NTP - Network Time Protocol} \framesubtitle{\texttt{ntpdate} - Set system time \& date} \begin{itemize} \item \texttt{ntpdate} is a command line utility that will set the local machines time \& date from the indicated remote time server(s). %\overlay{1} \item More than one server can be specified in order for ntp to get a better idea of the transit time and overall server accuracy. %\overlay{2} \item Running as a cron job is a simple way to maintain system time \end{itemize} %\overlay{3} Usage: \texttt{ntpdate [options] server ...} \footnotesize \begin{semiverbatim} \# ntpdate ntp.nml.csiro.au 21 May 14:01:13 ntpdate[4002]: adjust time server 10.27.1.10 offset -0.000804 sec \end{semiverbatim} \normalsize %\begin{overlay}{4} This will set the local machines system time using server \texttt{ntp.nml.csiro.au} %\end{overlay} \end{frame} %----------------------------------------------------------- %============================================================================== \begin{frame}[fragile] %Andrew Eager and Geoffrey \frametitle{\texttt{ntpd} - The NTP daemon} \begin{itemize} \item NTPD is a better way to maintain the system time on a permanent basis. %\overlay{1} \item NTPD acts as both a client \& server (Linux only). %\overlay{2} \item In server mode, other machines on the local network can use the server to set their own system clocks %\overlay{3} \item For Windows machines, automachron is available. %\overlay{4} \item NTPD also keeps track of RTC drift. \end{itemize} %\begin{overlay}{4} The NTP daemon is normally started up by the system initialisation scripts. \begin{description} \item[Debian]:{\footnotesize \cmd{/etc/init.d/ntp \{start|stop|restart|force-reload\} } } \item[RedHat]: {\footnotesize \cmd{service ntp start}} \end{description} %\end{overlay} \end{frame} %----------------------------------------------------------- %============================================================================== \begin{frame}[<+->] %Andrew Eager and Geoffrey \frametitle{\texttt{ntpd} usage \& configuration} Usage: \texttt{ntpd [options] \&} (normally done in the \texttt{/etc/init.d} scripts) NTPD is configured using these files: \begin{itemize} %\overlay{1} \item \texttt{/etc/ntp.conf} - Configuration file %\overlay{2} \item \texttt{/etc/ntp.drift} - RTC drift file %\overlay{3} \item \texttt{/etc/ntp.keys} - Key file (for authentication mode) \end{itemize} %\begin{overlay}{4} The only file of concern to the user is ntp.conf. The other files are all written to and read by the ntp applications. %\end{overlay} \end{frame} %----------------------------------------------------------- %============================================================================== \begin{frame}[fragile] %Andrew Eager %\frametitle{NTP - Network Time Protocol} \framesubtitle{Sample \texttt{ntp.conf} file} \footnotesize \begin{semiverbatim} # Disable authentication mode disable auth restrict default ignore # ignore all requests by default server ntp.cs.mu.OZ.AU # 128.250.36.2 server apphys16.mst.csiro.au # 138.194.21.154 server ntp.nml.csiro.au # 130.155.98.1 server 127.0.0.1 # localhost # Lift restrictions on time servers restrict 128.250.36.2 nomodify # time service only, no rt mods restrict 138.194.21.154 nomodify restrict 130.155.98.1 nomodify # All local addresses are unrestricted restrict 127.0.0.1 restrict 10.27.1.0 mask 255.255.255.0 # Set the default drift file driftfile /etc/ntp/drift \end{semiverbatim} \end{frame} %----------------------------------------------------------- %============================================================================== \begin{frame}[fragile] %Andrew Eager and Geoffrey \frametitle{Public Time Servers} A (partial) list of public time servers is shown below. When using these servers, it is considered polite to advise the administrator of the service that you intend on using it. \framesubtitle{Primary NTP Time Servers} \begin{itemize} \item ntp.cs.mu.OZ.AU (128.250.36.2) \item apphys16.mst.csiro.au (138.194.21.154) \item ntp.nml.csiro.au ( 130.155.98.1) \end{itemize} \framesubtitle{Secondary NTP Time Servers} \begin{itemize} \item ntp.saard.net (203.21.37.18) \item ntp.iprolink.co.nz (36.50.59.6) \end{itemize} \end{frame} %----------------------------------------------------------- %============================================================================== \begin{frame}[fragile] %Andrew Eager \frametitle{NTP - Network Time Protocol} \framesubtitle{Testing NTP} Once you have the NTP daemon up \& running, the easiest way of testing it is to use the ntpq utility. \footnotesize \begin{semiverbatim} # ntpq ntpq> pe remote refid ... delay offset jitter =========================================================== localhost.local 0.0.0.0 ... 0.000 0.000 4000.00 xmurgon.cs.mu.OZ .GPS. ... 526.202 -206.43 208.270 +apphys16.mst.cs .ATOM. ... 169.956 -5.576 87.828 *tictoc.tip.CSIR .ATOM. ... 149.988 -24.328 6.761 ntpq> q # \end{semiverbatim} \end{frame} %----------------------------------------------------------- %============================================================================== % \begin{frame}[fragile] % %ghr % \heading{The End} % \end{frame} %----------------------------------------------------------- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{License Of This Document} Copyright \copyright\ 2002 Geoffrey Robertson. Permission is granted to make and distribute verbatim copies or modified versions of this document provided that this copyright notice and this permission notice are preserved on all copies under the terms of the GNU General Public License as published by the Free Software Foundation---either version 2 of the License or (at your option) any later version. \end{frame} \end{document}