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