\section{chkconfig and service **}
\begin{frame}
   {chkconfig}

   \begin{itemize}
      \item Controls what system services run in each runlevel
      \item
      \begin{cmd}
$ chkconfig --list [some_service]
      \end{cmd}
      displays what in which run levels \verb?some_service? is enabled
      \item
      \begin{cmd}
$ chkconfig - [some_service] on
$ chkconfig - [some_service] off
      \end{cmd}
      controls whether or not \verb?some_service? starts at system boot.
      \item
      Does \textbf{not} start or stop a service without a reboot;
      for that use \textbf{service}
   \end{itemize}

\end{frame}

\cprotect\note{
   Check a particular service to see if it is set up to run
   in the the current runlevel:
   \begin{cmd}
$ chkconfig some_service
   \end{cmd}
   This will return true if the service is configured to
   be running, false otherwise.  Note that even if it is
   configured to be running it might currently be
   stopped.

   See what services are configured to run in each of
   the runlevels:
   \begin{cmd}
$ chkconfig --list [service names]
   \end{cmd}

   Turn on or do not turn on a certain service next time
   the system boots:
   \begin{cmd}
$ sudo chkconfig some_service [on|off]
   \end{cmd}

   It is not difficult to add your own services and write
   your own startup scripts.  One only has to place a
   script in \filelink{/etc/init.d} which has to have
   certain features in it (just some lines at the top!)
   and then use \verb?chkconfig --add? to enable or
   \verb?chkconfig --del? to disable use of the on and
   off instructions etc.

   \textbf{chkconfig} determines which
   number should appear after the \texttt{S} or \texttt{K}
   in a symbolic link, and which runlevels to
   set on or off and what state to set the symbolic links
   in, by examining the scripts themselves,
   which contain a line near the top like:
   \begin{cmd}
# chkconfig: 2345 10 90
   \end{cmd}

   The first argument is
   there to define which runlevels to have the service on
   by default in the above example that means levels 2, 3,
   4 and 5.
   The second and third numbers are the numerical prefixes
   in the start and stop scripts, so in the above they
   start with \texttt{S10} and \texttt{K90}.
}


\begin{frame}
   {service}
   \begin{itemize}
      \item Starts, stops, restarts, shows status of system services.
      \item
      \begin{cmd}
$ service some_service status
      \end{cmd}
      indicates whether \verb?some_service? is currently running
      \item
      \begin{cmd}
$ service some_service start
$ service some_service stop
$ service some_service restart
      \end{cmd}
      stops, starts, or restarts (stops and then starts)
      \verb?some_service?
      \item See the status of all system services:
      \begin{cmd}
$ sudo service --status-all
      \end{cmd}
   \end{itemize}

\end{frame}

\cprotect\note {

   Every operating system has \textbf{services} which are
   usually started on system initialization and often
   remain running until shutdown. Such services may be
   started, stopped, or restarted at any time, generally
   requiring root privilege.  On a \textbf{Linux} system
   using or emulating \textbf{SysVinit}, the services are
   those in the \filelink{/etc/init.d} directory.
   \begin{cmd}
$ sudo service vsftpd status
   \end{cmd}
   \begin{response}
vsftpd (pid 5284) is running...
   \end{response}

   \textbf{service} takes a number of options,
   which vary according to the particular service; for example:

   \begin{cmd}
$ sudo service network
   \end{cmd}
   \begin{response}
  Usage: /etc/init.d/network {start|stop|restart|reload|status}
   \end{response}
   \begin{cmd}
$ sudo service iptables
   \end{cmd}
   \begin{response}
  Usage: /etc/init.d/iptables {start|stop|restart|condrestart|status|panic|save}
   \end{response}

   All \textbf{service} really does is change directory to
   \filelink{/etc/init.d} and run the appropriate script
   in that directory with the supplied options.

   Starting and stopping services with \textbf{service} is
   only effective during the current operation of the
   system; all changes are lost upon reboot. To cause a
   particular service to be turned on or not during system
   initialization, on \textbf{Red Hat}-based systems one
   uses \textbf{chkconfig} as described earlier.

}




