129

I have come across a .service that contains the following:

[Install]
WantedBy=multi-user.target

The original .service file can be found here.

What is the the meaning of multi-user.target?

I am on Ubuntu 16.04 LTS.

4
  • 3
    Possible duplicate of What is systemd's target, service and socket? Commented Nov 15, 2017 at 8:49
  • 2
    It's not a proper duplicate, as (reading beyond the title) this question is asking about the [Install] section of a unit file. Ironically, it is the very next table down from the one hyperlinked in the question. Commented Nov 15, 2017 at 11:52
  • 1
    This new related question has a lot more details in the answer and is very well worth reading. Commented Mar 14, 2019 at 23:13
  • It really is, thanks for pointing there @Wildcard. Commented Jan 22, 2021 at 15:43

5 Answers 5

94

multi-user.target means that the systemd-service will start when the system reach runlevel 2.

To complement the answer, here's a table of the targets and their run levels:

Run Lvl Target Units                        Description
0       runlevel0.target, poweroff.target   Shut down and power off
1       runlevel1.target, rescue.target     Set up a rescue shell
2,3,4   runlevel[234].target,               Set up a non-gfx multi-user shell
        multi-user.target
5       runlevel5.target, graphical.target  Set up a gfx multi-user shell
6       runlevel6.target, reboot.target     Shut down and reboot the system
6
  • 1
    But it's WantedBy=multi-user.target, so it just means the service will start and before runlevel 2 right ? not necessarily when system reaches runlevel 2, am I wrong ? Commented Dec 10, 2018 at 17:53
  • 3
    What's a gfx multi-user shell? Any reference? Commented Oct 14, 2019 at 7:46
  • 1
    A gfx multi-user shell refer to a multi-user system with a GUI. Commented Oct 15, 2019 at 14:44
  • 2
    @TobiasHolm You might not be completely right, I'm getting the same target (graphical.target) even on a GUI-less Debian server with systemctl get-default. Commented Nov 27, 2021 at 10:30
  • FYI, see also man systemd.special and man runlevel. Commented Jan 17, 2024 at 8:32
29

This is the dependencies handling mechanism in Systemd.
multi-user.target is the alternative for runlevel 3 in SystemV world.

That said, reaching multi-user.target includes starting the Confluent ZooKeeper service.

That's probably what you need indeed.

2
  • 11
    pretty vague answer. amazed that it got the green tick. some people be like, knows a little, throws a brittle. Commented Aug 21, 2021 at 5:14
  • actually, it's pretty informative even for systemd disliking person - if one is not ready to grasp content, they shall start learning from scratch. Commented Feb 26, 2023 at 8:46
27

I found this landoflinux.com tutorial (webarchive) the simplest to understand. You can run the following command yourself to see what's there:

$ ls -al /lib/systemd/system/runlevel*
lrwxrwxrwx. 1 root root 15 Apr 25 10:31 /lib/systemd/system/runlevel0.target -> poweroff.target
lrwxrwxrwx. 1 root root 13 Apr 25 10:31 /lib/systemd/system/runlevel1.target -> rescue.target
lrwxrwxrwx. 1 root root 17 Apr 25 10:31 /lib/systemd/system/runlevel2.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 Apr 25 10:31 /lib/systemd/system/runlevel3.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 Apr 25 10:31 /lib/systemd/system/runlevel4.target -> multi-user.target
lrwxrwxrwx. 1 root root 16 Apr 25 10:31 /lib/systemd/system/runlevel5.target -> graphical.target
lrwxrwxrwx. 1 root root 13 Apr 25 10:31 /lib/systemd/system/runlevel6.target -> reboot.target

But you should probably just read the linked question accepted answer about targets.

2
  • 1
    "landoflinux.com" is now a gambling site. Commented May 1 at 4:44
  • 1
    @user5359531 cheers - used the archive link Commented May 18 at 18:44
6

tldr if a service is wanted by multi-user.target, the service requires a number of services needed for a non-graphical multi-user session to be started (see the required services in the chart below).

$ man systemd.special
...
multi-user.target

    A special target unit for setting up a multi-user system (non-graphical). This is pulled in by graphical.target.

    Units that are needed for a multi-user system shall add Wants= dependencies for their unit to this unit during installation. This is best configured via WantedBy=multi-user.target in the unit's [Install] section.
...

the services required by the target can be found in the chart below:

                             cryptsetup-pre.target veritysetup-pre.target
                                                  |
(various low-level                                v
 API VFS mounts:             (various cryptsetup/veritysetup devices...)
 mqueue, configfs,                                |    |
 debugfs, ...)                                    v    |
 |                                  cryptsetup.target  |
 |  (various swap                                 |    |    remote-fs-pre.target
 |   devices...)                                  |    |     |        |
 |    |                                           |    |     |        v
 |    v                       local-fs-pre.target |    |     |  (network file systems)
 |  swap.target                       |           |    v     v                 |
 |    |                               v           |  remote-cryptsetup.target  |
 |    |  (various low-level  (various mounts and  |  remote-veritysetup.target |
 |    |   services: udevd,    fsck services...)   |             |              |
 |    |   tmpfiles, random            |           |             |    remote-fs.target
 |    |   seed, sysctl, ...)          v           |             |              |
 |    |      |                 local-fs.target    |             | _____________/
 |    |      |                        |           |             |/
 \____|______|_______________   ______|___________/             |
                             \ /                                |
                              v                                 |
                       sysinit.target                           |
                              |                                 |
       ______________________/|\_____________________           |
      /              |        |      |               \          |
      |              |        |      |               |          |
      v              v        |      v               |          |
 (various       (various      |  (various            |          |
  timers...)      paths...)   |   sockets...)        |          |
      |              |        |      |               |          |
      v              v        |      v               |          |
timers.target  paths.target   |  sockets.target      |          |
      |              |        |      |               v          |
      v              \_______ | _____/         rescue.service   |
                             \|/                     |          |
                              v                      v          |
                          basic.target         rescue.target    |
                              |                                 |
                      ________v____________________             |
                     /              |              \            |
                     |              |              |            |
                     v              v              v            |
                 display-    (various system   (various system  |
             manager.service     services        services)      |
                     |         required for        |            |
                     |        graphical UIs)       v            v
                     |              |            multi-user.target
emergency.service    |              |              |
        |            \_____________ | _____________/
        v                          \|/
emergency.target                    v
                              graphical.target

source

the list of dependencies can also be found with

$ systemctl list-dependencies multi-user.target
0

TL;DR

multiuser.target is a system setting based terminal only meant for use on systems that do not have or require a graphical desktop environment. Such as for instance, a cluster.

The reference to runlevels is not really relevant, as they are not part of systemd. They are a set of system configurations (in this case 3 different ones) that you can use to determine which services will be started and which not.

But the short answer to your question is: multiuser.target is a special system configuration for a shell-only environment on multi-user systems that can be called at startup (or whenever you want, actually)/

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.