\begin{exe} {Adding a New Startup Service with systemd}

   To add a new startup service we need to create (as root) a file
   directly under \filelink{/etc/systemd/system} or
   somewhere else in that directory tree; distributions
   have some varying tastes on this.  For example a very
   minimal file named
   \filelink{/etc/systemd/system/fake2.service}
   (which can be extracted from your downloaded
   \verb?SOLUTIONS? file as
   \lablink{fake2.service})  containing the following:

   \fromfile[\texttt{fake2.service}]{labs/fake2.service}

   Now there are many things that can go in this
   \textbf{unit} file.  The \verb?After=network.target?
   means the service should start only after the network
   does, while the \verb?WantedBy=multi-user.target?  means
   it should start when we reach multiple-user mode. This is
   equivalent to runlevels 2 and 3 in \textbf{SysVinit}.
   Note \verb?graphical.target?  would correlate with
   runlevel 5.

   Now all we have to do to start, stop and check the
   service status are to issue the commands:
   \begin{cmd}
$ sudo systemctl start fake2.service
$ sudo systemctl status fake2.service
$ sudo systemctl stop fake2.service
   \end{cmd}
   If you are fiddling with the unit file while doing
   this you'll need to reload things with:
   \begin{cmd}
$ sudo systemctl daemon-reload
   \end{cmd}
   as the system will warn you.

   To keep an eye directly on the output you can do:
   \begin{cmd}
$ sudo tail -f /var/log/messages
   \end{cmd}
   (use \filelink{/var/log/syslog} on \textbf{Ubuntu})
   either in background or in another windows while the service is
   running.

   To set things up so the service turns on or off on
   system boot:
   \begin{cmd}
$ sudo systemctl enable fake2.service
$ sudo systemctl disable fake2.service
   \end{cmd}

   Once again, you really need to reboot to make sure it
   has taken effect.
\end{exe}

