pages tagged serviceyakkinghttp://yakking.branchable.com/tags/service/yakkingikiwiki2015-11-02T20:42:10ZSystemd 7 - cron, at and systemd timershttp://yakking.branchable.com/posts/systemd-7-crontab-and-timers/Richard Maw2015-11-02T20:42:10Z2015-10-28T12:00:07Z
<p>You will, from time to time,
feel the need to run a command at a specific time.</p>
<p><a href="http://linux.die.net/man/1/at">at(1)</a> will run a command at a specified time,
so if you need a reminder that you should go to bed at midnight,
you could run the following command:</p>
<pre><code>$ at midnight
at> echo Go to bed | wall ^D
</code></pre>
<p>If you instead need to run a command at regular times,
such as a <a href="http://liw.fi/">backup</a> job,
then you can add a persistent timed job with <a href="http://man7.org/linux/man-pages/man1/crontab.1.html">crontab(1)</a>.</p>
<p>You would run <code>crontab -e</code> to add a command to your crontab,
as described in <a href="http://man7.org/linux/man-pages/man5/crontab.5.html">crontab(5)</a>.</p>
<p>To run nightly <a href="http://obnam.org/">obnam</a> backup
(instructions taken from <a href="http://bastian.rieck.ru/blog/posts/2013/backups_with_obnam/">Bastian Rieck's blog</a>),
add the following to the crontab file.</p>
<pre><code>0 20 * * * /usr/bin/obnam backup $HOME
</code></pre>
<p>This could instead be written as a systemd timer unit,
which can be used without a separate cron service running,
by creating two configuration files as follows:</p>
<pre><code>$ mkdir -p ~/.config/systemd/user
$ cat >~/.config/systemd/user/backup.timer <<'EOF'
> [Unit]
> Description=Backup timer
> [Timer]
> OnCalendar=daily
> [Install]
> WantedBy=default.target
> EOF
$ cat >~/.config/systemd/user/backup.service <<'EOF'
> [Unit]
> Description=Backup Service
> [Service]
> Type=simple
> ExecStart=/usr/bin/obnam backup %h
> [Install]
> WantedBy=default.target
> EOF
$ systemctl --user daemon-reload
$ systemctl --user enable backup.timer backup.service
$ systemctl --user start backup.timer backup.service
</code></pre>
<p>This is more verbose than the cron syntax, though arguably less arcane.</p>
<p>However systemd timer units have the advantage
of allowing you to set <code>WakeSystem=</code>,
which will unsuspend your system to react to timer events.</p>
<p>There are instructions on how to use this to make an alarm clock
on <a href="http://joeyh.name/blog/entry/a_programmable_alarm_clock_using_systemd/">Joey Hess' blog</a>.</p>
systemd for the uninformed - networkinghttp://yakking.branchable.com/posts/systemd-6-networkd/Richard Maw2015-07-01T11:00:13Z2015-07-01T11:00:07Z
<p>Networking is one of the most important things a computer can do, since
it's no so useful on its own.</p>
<h1>systemd-networkd</h1>
<p>Networking under Linux is powerful, but managed by a set of wildly
different tools, with different capabilities and with very different
interfaces.</p>
<p>To handle this, <a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a> introduced <a href="http://www.freedesktop.org/software/systemd/man/systemd-networkd.html">networkd(8)</a> to provide a
common interface to all the network configuration, and is becoming a
standard way of doing this across the different distributions.</p>
<p>At the time of writing, <a href="http://www.freedesktop.org/software/systemd/man/systemd-networkd.html">networkd(8)</a> is intended to be
a replacement for static network config in the form of the
Debian-derived <a href="http://manpages.ubuntu.com/manpages/utopic/man5/interfaces.5.html">interfaces(5)</a> file, or the Red Hat-derived
<a href="http://www.linuxcertif.com/man/5/ifcfg/">ifcfg(5)</a>, rather than the dynamic network config managed by
<a href="https://wiki.gnome.org/Projects/NetworkManager">NetworkManager</a> or <a href="https://01.org/connman">connman</a>.</p>
<p>However, you can do some form of dynamic network configuration by
putting files in <code>/etc/systemd/network</code> and restarting <a href="http://www.freedesktop.org/software/systemd/man/systemd-networkd.html">networkd(8)</a>
by running <code>systemctl restart systemd-networkd.service</code>.</p>
<p>You can configure networks by adding a <a href="http://www.freedesktop.org/software/systemd/man/systemd.network.html">systemd.network(5)</a>
file, or create virtual network devices (such as bridges) with a
<a href="http://www.freedesktop.org/software/systemd/man/systemd.netdev.html">systemd.netdev(5)</a> file.</p>
<p>This is normally the domain of the system administrator, but <a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a>
ships a few default rules to make networking with containers launched with
[systemd-networkd(1)][] work better.</p>
<p><a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a> ships a rule for containers to use <a href="http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol">DHCP</a> on network
interfaces named <code>hostN</code>, to get their IP address. And ships a rule
such that the other end of these host-only interfaces provide a <a href="http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol">DHCP</a>
server, and use <a href="http://en.wikipedia.org/wiki/Network_address_translation">NAT</a> to allow containers to speak to the internet.</p>
<h1>systemd-resolved</h1>
<p><a href="http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol">DHCP</a> isn't the whole story though, as you need names to usefully
access the internet, so <a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a> has some support for <a href="http://en.wikipedia.org/wiki/Domain_Name_System">DNS</a>.</p>
<p><a href="http://www.freedesktop.org/software/systemd/man/systemd-resolved.html">resolved(8)</a> provides per-interface <a href="http://en.wikipedia.org/wiki/Hostname">DNS hostname</a> resolution. This
is an improtant improvement over the current state of Linux networking,
because network interfaces are a lot more dynamic than they used to be.</p>
<p>It is not unusual to be connected to multiple networks, especially if
you need to use a <a href="http://en.wikipedia.org/wiki/Virtual_private_network">VPN</a> to talk to machines that are not allowed to
connect to the internet.</p>
<p>If name resolution is not handled per-interface, then you need to flush
the <a href="http://en.wikipedia.org/wiki/Domain_Name_System">DNS</a> cache to avoid having entries that are only relevant to
networks you are no longer connected to.</p>
<p><a href="http://www.freedesktop.org/software/systemd/man/systemd-resolved.html">resolved(8)</a> is only indirectly used, via the standard name lookup
procedure specified in the "hosts" line in the <a href="http://man7.org/linux/man-pages/man5/nsswitch.conf.5.html">nsswitch.conf(5)</a>
file, by adding "resolve".</p>
<p><a href="http://www.freedesktop.org/software/systemd/man/systemd-resolved.html">resolved(8)</a> doesn't normally need further configuration, as name
resolution is typically per-network configuration, and this network
configuration is usually shared by a <a href="http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol">DHCP</a> server.</p>
<p>However, if this is not reliable, then the name servers can be configured
per-interface in a <a href="http://www.freedesktop.org/software/systemd/man/systemd.network.html">systemd.network(5)</a> file, or system-wide in the
[resolved.conf(5)][] configuration file.</p>
systemd for the uninformed - managing machineshttp://yakking.branchable.com/posts/systemd-5-machined/Richard Maw2015-06-18T09:00:51Z2015-06-17T11:00:09Z
<p><a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a> has a few services that are mostly just about providing
a common interface to information about the current machine, or other
machines.</p>
<h1>Daemons for recording information</h1>
<p>There's <a href="http://www.freedesktop.org/software/systemd/man/systemd-hostnamed.html">hostnamed(8)</a>, <a href="http://www.freedesktop.org/software/systemd/man/systemd-localed.html">localed(8)</a> and <a href="http://www.freedesktop.org/software/systemd/man/systemd-timedated.html">timedated(8)</a> for
providing a wirtable D-Bus interface to the system's hostname, locale
and time respectively; and <a href="http://www.freedesktop.org/software/systemd/man/systemd-machined.html">machined(8)</a>, which provides information
about the "chassis type" or "form factor".</p>
<p>It may sound wasteful to have an entire server just to make this
information available over D-Bus, but when a server is waiting for
requests it is often paged-out, meaning it's only consuming a small
amount of memory.</p>
<p>However, this wasn't good enough for the <a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a> developers, so
these services are D-Bus activated, which means that they'll only be
started when something makes a request of them. Combined with the fact
that these services will exit when idle, and they don't even need to
consume that small amount of memory any more.</p>
<p>One user of <a href="http://www.freedesktop.org/software/systemd/man/systemd-hostnamed.html">hostnamed(8)</a> is the <a href="http://www.freedesktop.org/software/systemd/man/nss-myhostname.html">myhostname</a> <a href="http://www.gnu.org/software/libc/manual/html_node/Name-Service-Switch.html">NSS</a> module,
which if <a href="http://www.gnu.org/software/libc/manual/html_node/NSS-Configuration-File.html#NSS-Configuration-File">nsswitch.conf</a> is configured correctly, allows the addresses
of the curent machine to be resolved without hard-coding them in the
<a href="http://man7.org/linux/man-pages/man5/hosts.5.html">hosts file</a>.</p>
<h1>machined supporting containers</h1>
<p><a href="http://www.freedesktop.org/software/systemd/man/systemd-machined.html">machined(8)</a> also manages information about other machines, though
this stretches the definition of "machine" a little, since it means
the host machine, containers and virtual machines, rather than
multiple physical machines on a network.</p>
<p><a href="http://www.freedesktop.org/software/systemd/man/systemd-machined.html">machined(8)</a> is usually used indiectly by your virtual-machine
manager or container manager, to provide a common interface for managing
them with <a href="http://www.freedesktop.org/software/systemd/man/machinectl.html">machinectl(1)</a>.</p>
<p>The usual management tasks aren't much more than just seeing which
machines are online and stopping them if necessary, but if a machine
is registered with <a href="http://www.freedesktop.org/software/systemd/man/systemd-machined.html">machined(8)</a>, then other <a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a> management
commands, such as <a href="http://www.freedesktop.org/software/systemd/man/systemctl.html">systemctl(1)</a> allow you to pass a machine name to
the <code>--machine</code> option, to get it to operate on that machine instead of
the host.</p>
<p><a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a> comes with a container manager built-in, called
<a href="http://www.freedesktop.org/software/systemd/man/systemd-nspawn.html">systemd-nspawn(1)</a>, which has more full integration with
<a href="http://www.freedesktop.org/software/systemd/man/machinectl.html">machinectl(1)</a>, allowing the download of container images, configuring
whether they start on-boot, and commands to log-in to the container and
copy files in or out.</p>
systemd for the uninformed - session and seat management with logindhttp://yakking.branchable.com/posts/systemd-4-logind/Richard Maw2015-05-27T11:00:14Z2015-05-27T11:00:08Z
<p><a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a> has a service for managing user sessions called <a href="http://www.freedesktop.org/software/systemd/man/systemd-logind.html">logind(8)</a>,
this replaces the existing <a href="http://www.freedesktop.org/wiki/Software/ConsoleKit/">ConsoleKit</a> tool, which was the previous
cross-desktop and cross-distribution tool.</p>
<p>This caused some controversy, as <a href="http://www.freedesktop.org/software/systemd/man/systemd-logind.html">logind(8)</a> is not usable without
<a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a>, and the fear was that this would cause distributions to
force the use of <a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a>.</p>
<p>There was some misplaced anger at both the <a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a> developers and the
<a href="https://www.gnome.org">GNOME</a> developers, when the <a href="https://www.gnome.org">GNOME</a> package maintainers in <a href="https://www.debian.org/">Debian</a>
decided to build <a href="https://www.gnome.org">GNOME</a> without <a href="http://www.freedesktop.org/wiki/Software/ConsoleKit/">ConsoleKit</a> support, as <a href="https://www.gnome.org">GNOME</a>
still supported being built with <a href="http://www.freedesktop.org/wiki/Software/ConsoleKit/">ConsoleKit</a>, and the <a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a>
developers are not responsible for other developers' decisions to support
<a href="http://www.freedesktop.org/software/systemd/man/systemd-logind.html">logind(8)</a> exclusively.</p>
<p>So, controversy aside, what does <a href="http://www.freedesktop.org/software/systemd/man/systemd-logind.html">logind(8)</a> provide to us?</p>
<h1>User session management</h1>
<p><a href="http://www.freedesktop.org/software/systemd/man/systemd-logind.html">logind(8)</a> tracks user log-ins and keeps track of which processes are
used, by use of a <a href="http://www.freedesktop.org/software/systemd/man/pam_systemd.html">pam_systemd</a> <a href="http://www.linux-pam.org/">PAM</a> module, so that processes can
be cleaned up when a user logs out, or the user is forced to log out,
such as when the administrator needs to perform maintainance, or the
user is no longer permitted to use the server.</p>
<p>There's little to no configuration needed by users for this aspect of
<a href="http://www.freedesktop.org/software/systemd/man/systemd-logind.html">logind(8)</a>, but if a user should be allowed to run processes after
they log out, such as if they run a <a href="http://man7.org/linux/man-pages/man1/screen.1.html">screen(1)</a> session, then this can
be allowed by using <a href="http://www.freedesktop.org/software/systemd/man/loginctl.html">loginctl(1)</a> to run <code>loginctl enable-linger $USER</code>.</p>
<h1>Seat assignment</h1>
<p>It's common these days for everybody to have their own computer, and
the only shared computers are servers, which you interact with via your
local comptuer, over a network.</p>
<p>However, back in the day, it was more common for there to be 1 computer
shared directly to multiple users, each with their own physical terminal.</p>
<p>Personal computing has made shared machines with multiple terminals
mostly unnecessary, but there's still a few uses, such as kiosks,
internet cafes, or classrooms, where it would be more cost efficient to
have people sharing the computer.</p>
<p>To make this work, <a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a> supports <a href="http://en.wikipedia.org/wiki/Multiseat_configuration">Multiseat configuration</a>,
by assigning multiple physical devices, such as a display, a keyboard
and a mouse, to different seats.</p>
<p>Some hardware is automatically configured as a separate seat, but
hardware can be explicitly assigned to a seat if these automatic rules
are incorrect, by using <code>loginctl attach SEAT DEVICE_PATH</code>.</p>
<h1>Hardware sleep</h1>
<p>If your computer is battery powered you may want the machine to go to
sleep when idle to save power, or you may want to block a system reboot
while performing crucial operations, like a system update.</p>
<p>To handle this, <a href="http://www.freedesktop.org/software/systemd/man/systemd-logind.html">logind(8)</a> allows you to take an <a href="http://www.freedesktop.org/wiki/Software/systemd/inhibit/">inhibit</a> lock,
which is implemented with file descriptor passing, so a crashing process
will automatically release it.</p>
<p>To use an inhibitor lock, either run a command with the
<a href="http://www.freedesktop.org/software/systemd/man/systemd-inhibit.html">systemd-inhibit(1)</a> wrapper command, or request a file descriptor
with the <a href="http://www.freedesktop.org/wiki/Software/systemd/logind/">logind D-Bus interface</a>.</p>
systemd for the uninformed - The Journalhttp://yakking.branchable.com/posts/systemd-3-journald/Richard Maw2015-04-29T11:00:15Z2015-04-29T11:00:09Z
<p><a href="http://www.freedesktop.org/software/systemd/man/systemd-journald.service.html">journald(8)</a> is for collecting log output from processes and textual
output from services started by <a href="http://www.freedesktop.org/software/systemd/man/systemd.html">systemd(1)</a>.</p>
<p>As is usual for things involving <a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a>, there's some controversy
surrounding it, because of some technical decisions and it being a
mandatory component in systems that use <a href="http://www.freedesktop.org/software/systemd/man/systemd.html">systemd(1)</a>.</p>
<p>The main concern is that it will replace the venerable <a href="http://man7.org/linux/man-pages/man8/rsyslogd.8.html">syslog</a>,
because <a href="http://www.freedesktop.org/software/systemd/man/systemd-journald.service.html">journald(8)</a> takes over the <code>/dev/log</code> socket used by the
<a href="http://man7.org/linux/man-pages/man3/syslog.3.html">syslog(3)</a> logging protocol. However, this does not actually force
you to use the Journal, as <a href="http://man7.org/linux/man-pages/man8/rsyslogd.8.html">rsyslogd(8)</a> can read information out of
the journal.</p>
<p>The other concern with <a href="http://www.freedesktop.org/software/systemd/man/systemd-journald.service.html">journald(8)</a> is that it saves logs in a binary
format requiring it to be read out with <a href="http://www.freedesktop.org/software/systemd/man/journalctl.html">journalctl(1)</a>, as opposed
to <a href="http://man7.org/linux/man-pages/man8/rsyslogd.8.html">syslog</a>, which saves logs as a text file, so can be processed by
other tools.</p>
<p>The source of concern is that the Journal may change to an incompatible
format, and there wouldn't be any way to read the logs out, but this
can be mitigated by installing <a href="http://man7.org/linux/man-pages/man8/rsyslogd.8.html">rsyslogd(8)</a> in case it ever happens,
and the systemd developers have been careful about keeping it backwards
compatible.</p>
<p>The reason for the journal storing logs in a binary format, is for
performance when searching, as the journal contains more logging
information than <a href="http://man7.org/linux/man-pages/man8/rsyslogd.8.html">syslog</a> used to handle.</p>
<p>By default, the Journal stores the standard output and standard error of
services in addition to <a href="http://man7.org/linux/man-pages/man3/syslog.3.html">syslog(3)</a> output. This is usually sufficient,
but applications can send messages directly too with the <a href="http://www.freedesktop.org/software/systemd/man/sd-journal.html">sd-journal(3)</a>
library.</p>
<p>There is not a great deal of configuration required to use
<a href="http://www.freedesktop.org/software/systemd/man/systemd-journald.service.html">journald(8)</a>, but reading messages is possible with the
<a href="http://www.freedesktop.org/software/systemd/man/journalctl.html">journalctl(1)</a> tool.</p>
<p>I find the most useful option to <a href="http://www.freedesktop.org/software/systemd/man/journalctl.html">journalctl(1)</a> is <code>--unit</code>, which most
recently saved me a lot of time when debugging service start-up issues,
as it allowed me to deduce why things were failing to work properly.</p>
systemd for the uninformed - udev device managementhttp://yakking.branchable.com/posts/systemd-2-udevd/Richard Maw2015-04-15T11:00:16Z2015-04-15T11:00:10Z
<p><a href="http://www.freedesktop.org/software/systemd/man/udev.html">udev(8)</a> is the latest development in the complicated history of
device management in Linux. It has not been entirely uncontroversial. It
was previously hated for its decision to change syntax. Its integration
into systemd caused the <a href="http://www.gentoo.org/proj/en/eudev/">eudev</a> fork to happen, and the decision to
remove firmware loading support made Linus grumble.</p>
<p>This article isn't about that though, this is about what <a href="http://www.freedesktop.org/software/systemd/man/udev.html">udev(8)</a>
is, what it can do, and how you would use it.</p>
<p><a href="http://www.freedesktop.org/software/systemd/man/udev.html">udev(8)</a> is for managing the contents of <code>/dev</code> to handle permissions
of which users and groups may access devices under which names, and
providing an API for other services to use to recieve notification of
when devices change.</p>
<p>You tend not to need to interact with <a href="http://www.freedesktop.org/software/systemd/man/udev.html">udev(8)</a> directly unless you
have obscure hardware that you need to categorise, or you need to perform
actions when a device appears.</p>
<h2>Granting permission to access devices</h2>
<p>If the device has already been processed such that there's an entry in
<code>/dev</code>, then you can use <a href="http://www.freedesktop.org/software/systemd/man/udevadm.html">udevadm(8)</a> and the steps in this ArchLinux
wiki page on <a href="https://wiki.archlinux.org/index.php/udev#Writing_udev_rules">writing udev rules</a> to work out how to create a persistent
symlink.</p>
<p>To change the owner of the file, so you don't need to be root to use it,
you can add <code>GROUP="GROUPNAME"</code>, subtituting the group name wanted, and
set file permission bits with <code>MODE="0660"</code> to make that group able to
read or write to that device.</p>
<h2>Performing actions when a device appears</h2>
<h3>Short, simple scripts</h3>
<p>The simplest way to do this is to add <code>RUN+="/path/to/your/script"</code>
to your <a href="http://www.freedesktop.org/software/systemd/man/udev.html">udev(8)</a> rule, however this is only suitable for short-lived
scripts, as they will be killed if they are stil running after a timeout
period.</p>
<h3>Starting a daemon per-device</h3>
<p>If you need a longer-running service, then you should integrate it with
a systemd unit, by defining the unit like:</p>
<pre><code>cat >/etc/systemd/system/my-service@.service <<'EOF'
[Unit]
Description=My Service
[Service]
Type=simple
ExecStart=/path/to/your/script %I
EOF
</code></pre>
<p>And add <code>ENV{SYSTEMD_WANTS}="my-service@%k.service"</code> to the udev rule.</p>
<p>This will run <code>/path/to/your/script</code> and pass it the path to the device
that has just appeared.</p>
<h3>Handling device events from a currently-running daemon</h3>
<p>Sometimes it is not appropriate to have a model where there is an instance
of your service running for every device that is added. In this case,
it is more appropriate to have your service listen for udev events and
handle the devices when they appear itself.</p>
<p>The details on how to do this vary with the programming language bindings,
but the general flow is:</p>
<ol>
<li>Initialize the udev library context</li>
<li>Create a udev monitor</li>
<li>Configure the monitor to filter it to the class of devices you care about</li>
<li>Add the monitor to an event loop</li>
<li>Wait for udev to have a matching entry for you</li>
<li>Read the device entry out of udev and process the event</li>
</ol>
<p>Depending on your programming language of choice, you may want a guide
for how to <a href="http://www.signal11.us/oss/udev/udev_example.c">listen for devices with libudev</a>, or <a href="http://pyudev.readthedocs.org/en/latest/guide.html">pyudev</a>.</p>
systemd for the uninformedhttp://yakking.branchable.com/posts/systemd-1/Richard Maw2015-04-02T09:19:17Z2015-04-01T11:00:09Z
<h1>Disclaimer</h1>
<p><a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a> is a contentious issue in the Linux world, you don't need
to go far to read arguments for or against systemd. This article is not
about whether it's good or bad, but in the interests of full disclosiure,
I feel it is important to declare that I am a systemd contributor,
as at the time of writing I have <a href="http://cgit.freedesktop.org/systemd/systemd/commit/?id=d422e52a3523ad0955bec4f9fbed46e234d28590">1 line of code in systemd</a>. Hence I am
biased, as I wouldn't waste my time on something I didn't think was
worthwhile.</p>
<h1>What's with the title?</h1>
<p>One of the lead developers wrote an article series called <a href="http://0pointer.de/blog/projects/systemd-for-admins-1.html">systemd for
administrators</a>. The goal of which is to explain how useful <a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a>
is for system administrators, but the <a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a> project has widened in
scope since then, and the full scope of what <a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a> provides is
not common knowledge.</p>
<h1>What is systemd</h1>
<p><a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a> is both the name of a project to provide the boring bits
needed to have a working Linux system, and the name of the init process
<a href="http://www.freedesktop.org/software/systemd/man/systemd.html">systemd(1)</a>, which is the first process run in a Linux system, and
is responsible for starting all others.</p>
<h2>systemd as PID 1</h2>
<p><a href="http://www.freedesktop.org/software/systemd/man/systemd.html">systemd(1)</a> for initial start-up and management of services</p>
<p>You configure services by putting <a href="http://www.freedesktop.org/software/systemd/man/systemd.service.html">systemd.service(5)</a> files
in <code>/etc/systemd/system</code>, and do run-time manipulation with the
<a href="http://www.freedesktop.org/software/systemd/man/systemctl.html">systemctl(1)</a> tool.</p>
<p><a href="http://www.freedesktop.org/software/systemd/man/systemd.service.html">systemd.service(5)</a> files are a <a href="http://en.wikipedia.org/wiki/Domain-specific_language">DSL</a> for all the tricky start-up
configurations that were previously encoded in fragile init scripts,
and generalises the on-demand service start-up in <a href="http://www.freebsd.org/cgi/man.cgi?inetd(8)">inetd(8)</a>
into socket activation.</p>
<p>One of the trickiest parts of start-up is ensuring correct dependency
ordering, so services that depend on other services are started
after they are ready.</p>
<p>To handle this, you can set <code>Before=</code> in the service file you depend
on, or <code>After=</code> in your unit file, and ensure that your services
set the right <a href="https://wiki.archlinux.org/index.php/systemd#Service_types">Type=</a> section to notify when the service is ready.</p>
<p>For one-off commands that you'd still like to benefit from
<a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a>'s service management, you can use <a href="http://www.freedesktop.org/software/systemd/man/systemd-run.html">systemd-run(1)</a>.</p>
<h1>Conclusion</h1>
<p>I emphasised the difference between <a href="http://www.freedesktop.org/wiki/Software/systemd/">systemd</a> the project and
<a href="http://www.freedesktop.org/software/systemd/man/systemd.html">systemd(1)</a> the daemon that inhabits PID 1, because there are other
services provided by the former than just the latter, which will be
descibed in future articles.</p>