| 1 |
<?xml version="1.0"?> |
| 2 |
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
| 3 |
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> |
| 4 |
<!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
| 5 |
|
| 6 |
<refentry id="user_.service"> |
| 7 |
<refentryinfo> |
| 8 |
<title>[email protected]</title> |
| 9 |
<productname>systemd</productname> |
| 10 |
</refentryinfo> |
| 11 |
|
| 12 |
<refmeta> |
| 13 |
<refentrytitle>[email protected]</refentrytitle> |
| 14 |
<manvolnum>5</manvolnum> |
| 15 |
</refmeta> |
| 16 |
|
| 17 |
<refnamediv> |
| 18 |
<refname>[email protected]</refname> |
| 19 |
<refname>[email protected]</refname> |
| 20 |
<refname>systemd-user-runtime-dir</refname> |
| 21 |
<refpurpose>System units to start the user manager</refpurpose> |
| 22 |
</refnamediv> |
| 23 |
|
| 24 |
<refsynopsisdiv> |
| 25 |
<para><filename>user@<replaceable>UID</replaceable>.service</filename></para> |
| 26 |
<para><filename>user-runtime-dir@<replaceable>UID</replaceable>.service</filename></para> |
| 27 |
<para><filename>/usr/lib/systemd/systemd-user-runtime-dir</filename></para> |
| 28 |
<para><filename>user-<replaceable>UID</replaceable>.slice</filename></para> |
| 29 |
</refsynopsisdiv> |
| 30 |
|
| 31 |
<refsect1> |
| 32 |
<title>Description</title> |
| 33 |
|
| 34 |
<para>The <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
| 35 |
system manager (PID 1) starts user manager instances as |
| 36 |
<filename>user@<replaceable>UID</replaceable>.service</filename>, with the user's numerical UID used as |
| 37 |
the instance identifier. These instances use the same executable as the system manager, but running in a |
| 38 |
mode where it starts a different set of units. Each <command>systemd --user</command> instance manages a |
| 39 |
hierarchy of units specific to that user. See |
| 40 |
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> for a |
| 41 |
discussion of units and |
| 42 |
<citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry> for a |
| 43 |
list of units that form the basis of the unit hierarchies of system and user units.</para> |
| 44 |
|
| 45 |
<para><filename>user@<replaceable>UID</replaceable>.service</filename> is accompanied by the system unit |
| 46 |
<filename>user-runtime-dir@<replaceable>UID</replaceable>.service</filename>, which creates the user's |
| 47 |
runtime directory <filename>/run/user/<replaceable>UID</replaceable></filename> when started, and removes |
| 48 |
it when it is stopped. It also might apply runtime quota settings on <filename>/tmp/</filename> and/or |
| 49 |
<filename>/dev/shm/</filename> for the |
| 50 |
user. <filename>user-runtime-dir@<replaceable>UID</replaceable>.service</filename> executes the |
| 51 |
<filename>systemd-user-runtime-dir</filename> binary to do the actual work.</para> |
| 52 |
|
| 53 |
<para>User processes may be started by the <filename>[email protected]</filename> instance, in which |
| 54 |
case they will be part of that unit in the system hierarchy. They may also be started elsewhere, |
| 55 |
for example by |
| 56 |
<citerefentry project='man-pages'><refentrytitle>sshd</refentrytitle><manvolnum>8</manvolnum></citerefentry> or a |
| 57 |
display manager like <command>gdm</command>, in which case they form a .scope unit (see |
| 58 |
<citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>). |
| 59 |
Both <filename>user@<replaceable>UID</replaceable>.service</filename> and the scope units are |
| 60 |
collected under the <filename>user-<replaceable>UID</replaceable>.slice</filename>.</para> |
| 61 |
|
| 62 |
<para>Individual <filename>user-<replaceable>UID</replaceable>.slice</filename> slices are |
| 63 |
collected under <filename>user.slice</filename>, see |
| 64 |
<citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>. |
| 65 |
</para> |
| 66 |
</refsect1> |
| 67 |
|
| 68 |
<refsect1> |
| 69 |
<title>Controlling resources for logged-in users</title> |
| 70 |
|
| 71 |
<para>Options that control resources available to logged-in users can be configured at a few |
| 72 |
different levels. As described in the previous section, <filename>user.slice</filename> contains |
| 73 |
processes of all users, so any resource limits on that slice apply to all users together. The |
| 74 |
usual way to configure them would be through drop-ins, e.g. <filename |
| 75 |
index="false">/etc/systemd/system/user.slice.d/resources.conf</filename>. |
| 76 |
</para> |
| 77 |
|
| 78 |
<para>The processes of a single user are collected under |
| 79 |
<filename>user-<replaceable>UID</replaceable>.slice</filename>. Resource limits for that user |
| 80 |
can be configured through drop-ins for that unit, e.g. <filename |
| 81 |
index="false">/etc/systemd/system/user-1000.slice.d/resources.conf</filename>. If the limits |
| 82 |
should apply to all users instead, they may be configured through drop-ins for the truncated |
| 83 |
unit name, <filename>user-.slice</filename>. For example, configuration in <filename |
| 84 |
index="false">/etc/systemd/system/user-.slice.d/resources.conf</filename> is included in all |
| 85 |
<filename>user-<replaceable>UID</replaceable>.slice</filename> units, see |
| 86 |
<citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> |
| 87 |
for a discussion of the drop-in mechanism.</para> |
| 88 |
|
| 89 |
<para>When a user logs in and a .scope unit is created for the session (see previous section), |
| 90 |
the creation of the scope may be managed through |
| 91 |
<citerefentry><refentrytitle>pam_systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry>. |
| 92 |
This PAM module communicates with |
| 93 |
<citerefentry><refentrytitle>systemd-logind</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
| 94 |
to create the session scope and provide access to hardware resources. Resource limits for the |
| 95 |
scope may be configured through the PAM module configuration, see |
| 96 |
<citerefentry><refentrytitle>pam_systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry>. |
| 97 |
Configuring them through the normal unit configuration is also possible, but since |
| 98 |
the name of the slice unit is generally unpredictable, this is less useful.</para> |
| 99 |
|
| 100 |
<para>In general any resources that apply to units may be set for |
| 101 |
<filename>user@<replaceable>UID</replaceable>.service</filename> and the slice |
| 102 |
units discussed above, see |
| 103 |
<citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry> |
| 104 |
for an overview.</para> |
| 105 |
</refsect1> |
| 106 |
|
| 107 |
<refsect1> |
| 108 |
<title>Examples</title> |
| 109 |
<example> |
| 110 |
<title>Hierarchy of control groups with two logged in users</title> |
| 111 |
|
| 112 |
<programlisting>$ systemd-cgls |
| 113 |
Control group /: |
| 114 |
-.slice |
| 115 |
├─user.slice |
| 116 |
│ ├─user-1000.slice |
| 117 |
│ │ ├─[email protected] |
| 118 |
│ │ │ ├─pulseaudio.service |
| 119 |
│ │ │ │ └─2386 /usr/bin/pulseaudio --daemonize=no |
| 120 |
│ │ │ └─gnome-terminal-server.service |
| 121 |
│ │ │ └─init.scope |
| 122 |
│ │ │ ├─ 4127 /usr/libexec/gnome-terminal-server |
| 123 |
│ │ │ └─ 4198 zsh |
| 124 |
│ │ … |
| 125 |
│ │ └─session-4.scope |
| 126 |
│ │ ├─ 1264 gdm-session-worker [pam/gdm-password] |
| 127 |
│ │ ├─ 2339 /usr/bin/gnome-shell |
| 128 |
│ │ … |
| 129 |
│ │ ├─session-19.scope |
| 130 |
│ │ ├─6497 sshd: zbyszek [priv] |
| 131 |
│ │ ├─6502 sshd: zbyszek@pts/6 |
| 132 |
│ │ ├─6509 -zsh |
| 133 |
│ │ └─6602 systemd-cgls --no-pager |
| 134 |
│ … |
| 135 |
│ └─user-1001.slice |
| 136 |
│ ├─session-20.scope |
| 137 |
│ │ ├─6675 sshd: guest [priv] |
| 138 |
│ │ ├─6708 sshd: guest@pts/6 |
| 139 |
│ │ └─6717 -bash |
| 140 |
│ └─[email protected] |
| 141 |
│ ├─init.scope |
| 142 |
│ │ ├─6680 /usr/lib/systemd/systemd --user |
| 143 |
│ │ └─6688 (sd-pam) |
| 144 |
│ └─sleep.service |
| 145 |
│ └─6706 /usr/bin/sleep 30 |
| 146 |
…</programlisting> |
| 147 |
<para>User with UID 1000 is logged in using <command>gdm</command> (<filename |
| 148 |
index="false">session-4.scope</filename>) and |
| 149 |
<citerefentry project='man-pages'><refentrytitle>ssh</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
| 150 |
(<filename index="false">session-19.scope</filename>), and also has a user manager instance |
| 151 |
running (<filename index="false">[email protected]</filename>). User with UID 1001 is logged |
| 152 |
in using <command>ssh</command> (<filename index="false">session-20.scope</filename>) and |
| 153 |
also has a user manager instance running (<filename |
| 154 |
index="false">[email protected]</filename>). Those are all (leaf) system units, and form |
| 155 |
part of the slice hierarchy, with <filename index="false">user-1000.slice</filename> and |
| 156 |
<filename index="false">user-1001.slice</filename> below <filename |
| 157 |
index="false">user.slice</filename>. User units are visible below the |
| 158 |
<filename>[email protected]</filename> instances (<filename |
| 159 |
index="false">pulseaudio.service</filename>, <filename |
| 160 |
index="false">gnome-terminal-server.service</filename>, <filename |
| 161 |
index="false">init.scope</filename>, <filename index="false">sleep.service</filename>). |
| 162 |
</para> |
| 163 |
</example> |
| 164 |
|
| 165 |
<example> |
| 166 |
<title>Default user resource limits</title> |
| 167 |
|
| 168 |
<programlisting>$ systemctl cat user-1000.slice |
| 169 |
# /usr/lib/systemd/system/user-.slice.d/10-defaults.conf |
| 170 |
# … |
| 171 |
[Unit] |
| 172 |
Description=User Slice of UID %j |
| 173 |
After=systemd-user-sessions.service |
| 174 |
|
| 175 |
[Slice] |
| 176 |
TasksMax=33%</programlisting> |
| 177 |
<para>The <filename>user-<replaceable>UID</replaceable>.slice</filename> units by default do not |
| 178 |
have a unit file. The resource limits are set through a drop-in, which can be easily replaced |
| 179 |
or extended following standard drop-in mechanisms discussed in the first section.</para> |
| 180 |
</example> |
| 181 |
</refsect1> |
| 182 |
|
| 183 |
<refsect1> |
| 184 |
<title>See Also</title> |
| 185 |
<para><simplelist type="inline"> |
| 186 |
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 187 |
<member><citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry></member> |
| 188 |
<member><citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry></member> |
| 189 |
<member><citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry></member> |
| 190 |
<member><citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry></member> |
| 191 |
<member><citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry></member> |
| 192 |
<member><citerefentry><refentrytitle>[email protected]</refentrytitle><manvolnum>5</manvolnum></citerefentry></member> |
| 193 |
<member><citerefentry project='man-pages'><refentrytitle>pam</refentrytitle><manvolnum>8</manvolnum></citerefentry></member> |
| 194 |
</simplelist></para> |
| 195 |
</refsect1> |
| 196 |
</refentry> |