Understanding the structure of a target file
As I've said before, the best way to learn systemd
is to look at examples of the various unit files. In this section, we'll look at some .target
files.
Understanding the sockets.target file
Let's start with the sockets.target
file, which is one of the simplest targets we have:
[Unit] Description=Sockets Documentation=man:systemd.special(7)
Yeah, that's it, the entire file. The [Unit]
section is the only section it has, and it only consists of the Description=
line and the Documentation=
line. At first glance, you would think that this can't possibly be doing anything for us. But that's where you'd be wrong. Look in the /etc/systemd/system/sockets.target.wants
directory, and you'll see that this target is just a group of all the sockets that we need to have running:
[donnie@localhost sockets.target.wants]$ ls -l total 0 lrwxrwxrwx. 1 root 43 May 1 17:27 avahi-daemon.socket...