Posted in Linux commands

systemd, Part II: Using systemd as Normal User

In an earlier post we learned how to start a daemon with systemd. But it is annoying to handle a user daemon this way: type every time a sudo in front of the systemctl command. Let’s configure it, so that it can be used as a normal user.

To enable systemd for a user, root has to allow this:

# loginctl enable-linger maker

(maker is the username here). This is a one-time action for a specific user. After root has done this, the user can use systemd for his or her own daemons.

The configuration files are not in /etc/systemd/system (of course, because only root is allowed to write there), but in ~/.config/systemd/user/. So let’s create a file sensor.service in this directory:

Description=sensornet main daemon

All the rest is handled with the usual systemd commands with a little detail: you have to add the --user flag to the commands:

$ systemctl --user enable sensor
$ systemctl --user start sensor
$ systemctl --user status sensor

Additionally the user daemon is started at boot time.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s