1USER@.SERVICE(5) user@.service USER@.SERVICE(5)
2
3
4
6 user@.service, user-runtime-dir@.service, systemd-user-runtime-dir -
7 System units to start the user manager
8
10 user@UID.service
11
12 user-runtime-dir@UID.service
13
14 /usr/lib/systemd/systemd-user-runtime-dir
15
16 user-UID.slice
17
19 The systemd(1) system manager (PID 1) starts user manager instances as
20 user@UID.service, with the user's numerical UID used as the instance
21 identifier. These instances use the same executable as the system
22 manager, but running in a mode where it starts a different set of
23 units. Each systemd --user instance manages a hierarchy of units
24 specific to that user. See systemd(1) for a discussion of units and
25 systemd.special(7) for a list of units that form the basis of the unit
26 hierarchies of system and user units.
27
28 user@UID.service is accompanied by the system unit
29 user-runtime-dir@UID.service, which creates the user's runtime
30 directory /run/user/UID, and then removes it when this unit is stopped.
31 user-runtime-dir@UID.service executes the systemd-user-runtime-dir
32 binary to do the actual work.
33
34 User processes may be started by the user@.service instance, in which
35 case they will be part of that unit in the system hierarchy. They may
36 also be started elsewhere, for example by sshd(8) or a display manager
37 like gdm, in which case they form a .scope unit (see systemd.scope(5)).
38 Both user@UID.service and the scope units are collected under the
39 user-UID.slice.
40
41 Individual user-UID.slice slices are collected under user.slice, see
42 systemd.special(7).
43
45 Options that control resources available to logged-in users can be
46 configured at a few different levels. As described in the previous
47 section, user.slice contains processes of all users, so any resource
48 limits on that slice apply to all users together. The usual way to
49 configure them would be through drop-ins, e.g.
50 /etc/systemd/system/user.slice.d/resources.conf.
51
52 The processes of a single user are collected under user-UID.slice.
53 Resource limits for that user can be configured through drop-ins for
54 that unit, e.g. /etc/systemd/system/user-1000.slice.d/resources.conf.
55 If the limits should apply to all users instead, they may be configured
56 through drop-ins for the truncated unit name, user-.slice. For example,
57 configuration in /etc/systemd/system/user-.slice.d/resources.conf is
58 included in all user-UID.slice units, see systemd.unit(5) for a
59 discussion of the drop-in mechanism.
60
61 When a user logs in and a .scope unit is created for the session (see
62 previous section), the creation of the scope may be managed through
63 pam_systemd(8). This PAM module communicates with systemd-logind(8) to
64 create the session scope and provide access to hardware resources.
65 Resource limits for the scope may be configured through the PAM module
66 configuration, see pam_systemd(8). Configuring them through the normal
67 unit configuration is also possible, but since the name of the slice
68 unit is generally unpredictable, this is less useful.
69
70 In general any resources that apply to units may be set for
71 user@UID.service and the slice units discussed above, see
72 systemd.resource-control(5) for an overview.
73
75 Example 1. Hierarchy of control groups with two logged in users
76
77 $ systemd-cgls
78 Control group /:
79 -.slice
80 ├─user.slice
81 │ ├─user-1000.slice
82 │ │ ├─user@1000.service
83 │ │ │ ├─pulseaudio.service
84 │ │ │ │ └─2386 /usr/bin/pulseaudio --daemonize=no
85 │ │ │ └─gnome-terminal-server.service
86 │ │ │ └─init.scope
87 │ │ │ ├─ 4127 /usr/libexec/gnome-terminal-server
88 │ │ │ └─ 4198 zsh
89 │ │ ...
90 │ │ └─session-4.scope
91 │ │ ├─ 1264 gdm-session-worker [pam/gdm-password]
92 │ │ ├─ 2339 /usr/bin/gnome-shell
93 │ │ ...
94 │ │ ├─session-19.scope
95 │ │ ├─6497 sshd: zbyszek [priv]
96 │ │ ├─6502 sshd: zbyszek@pts/6
97 │ │ ├─6509 -zsh
98 │ │ └─6602 systemd-cgls --no-pager
99 │ ...
100 │ └─user-1001.slice
101 │ ├─session-20.scope
102 │ │ ├─6675 sshd: guest [priv]
103 │ │ ├─6708 sshd: guest@pts/6
104 │ │ └─6717 -bash
105 │ └─user@1001.service
106 │ ├─init.scope
107 │ │ ├─6680 /usr/lib/systemd/systemd --user
108 │ │ └─6688 (sd-pam)
109 │ └─sleep.service
110 │ └─6706 /usr/bin/sleep 30
111 ...
112
113 User with UID 1000 is logged in using gdm (session-4.scope) and ssh(1)
114 (session-19.scope), and also has a user manager instance running
115 (user@1000.service). User with UID 1001 is logged in using ssh
116 (session-20.scope) and also has a user manager instance running
117 (user@1001.service). Those are all (leaf) system units, and form part
118 of the slice hierarchy, with user-1000.slice and user-1001.slice below
119 user.slice. User units are visible below the user@.service instances
120 (pulseaudio.service, gnome-terminal-server.service, init.scope,
121 sleep.service).
122
123 Example 2. Default user resource limits
124
125 $ systemctl cat user-1000.slice
126 # /usr/lib/systemd/system/user-.slice.d/10-defaults.conf
127 # ...
128 [Unit]
129 Description=User Slice of UID %j
130 After=systemd-user-sessions.service
131
132 [Slice]
133 TasksMax=33%
134
135 The user-UID.slice units by default don't have a unit file. The
136 resource limits are set through a drop-in, which can be easily replaced
137 or extended following standard drop-in mechanisms discussed in the
138 first section.
139
141 systemd(1), systemd.service(5), systemd.slice(5), systemd.resource-
142 control(5), systemd.exec(5), systemd.special(7), pam(8)
143
144
145
146systemd 246 USER@.SERVICE(5)