1 <?xml-stylesheet type="text/xsl" href="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 This file is part of systemd.
8 Copyright 2010 Lennart Poettering
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 <refentry id="systemd.exec">
26 <title>systemd.exec</title>
27 <productname>systemd</productname>
31 <contrib>Developer</contrib>
32 <firstname>Lennart</firstname>
33 <surname>Poettering</surname>
34 <email>lennart@poettering.net</email>
40 <refentrytitle>systemd.exec</refentrytitle>
41 <manvolnum>5</manvolnum>
45 <refname>systemd.exec</refname>
46 <refpurpose>Execution environment configuration</refpurpose>
50 <para><filename><replaceable>service</replaceable>.service</filename>,
51 <filename><replaceable>socket</replaceable>.socket</filename>,
52 <filename><replaceable>mount</replaceable>.mount</filename>,
53 <filename><replaceable>swap</replaceable>.swap</filename></para>
57 <title>Description</title>
59 <para>Unit configuration files for services, sockets,
60 mount points, and swap devices share a subset of
61 configuration options which define the execution
62 environment of spawned processes.</para>
64 <para>This man page lists the configuration options
65 shared by these four unit types. See
66 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
67 for the common options of all unit configuration
69 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
70 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
71 <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
73 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
74 for more information on the specific unit
75 configuration files. The execution specific
76 configuration options are configured in the [Service],
77 [Socket], [Mount], or [Swap] sections, depending on the unit
82 <title>Options</title>
84 <variablelist class='unit-directives'>
87 <term><varname>WorkingDirectory=</varname></term>
89 <listitem><para>Takes an absolute
90 directory path. Sets the working
91 directory for executed processes. If
92 not set, defaults to the root directory
93 when systemd is running as a system
94 instance and the respective user's
95 home directory if run as
96 user.</para></listitem>
100 <term><varname>RootDirectory=</varname></term>
102 <listitem><para>Takes an absolute
103 directory path. Sets the root
104 directory for executed processes, with
106 <citerefentry><refentrytitle>chroot</refentrytitle><manvolnum>2</manvolnum></citerefentry>
107 system call. If this is used, it must
108 be ensured that the process and all
109 its auxiliary files are available in
110 the <function>chroot()</function>
111 jail.</para></listitem>
115 <term><varname>User=</varname></term>
116 <term><varname>Group=</varname></term>
118 <listitem><para>Sets the Unix user
119 or group that the processes are executed
120 as, respectively. Takes a single user or group
121 name or ID as argument. If no group is
122 set, the default group of the user is
123 chosen.</para></listitem>
127 <term><varname>SupplementaryGroups=</varname></term>
129 <listitem><para>Sets the supplementary
130 Unix groups the processes are executed
131 as. This takes a space-separated list
132 of group names or IDs. This option may
133 be specified more than once in which
134 case all listed groups are set as
135 supplementary groups. When the empty
136 string is assigned the list of
137 supplementary groups is reset, and all
138 assignments prior to this one will
139 have no effect. In any way, this
140 option does not override, but extends
141 the list of supplementary groups
142 configured in the system group
144 user.</para></listitem>
148 <term><varname>Nice=</varname></term>
150 <listitem><para>Sets the default nice
151 level (scheduling priority) for
152 executed processes. Takes an integer
153 between -20 (highest priority) and 19
154 (lowest priority). See
155 <citerefentry><refentrytitle>setpriority</refentrytitle><manvolnum>2</manvolnum></citerefentry>
156 for details.</para></listitem>
160 <term><varname>OOMScoreAdjust=</varname></term>
162 <listitem><para>Sets the adjustment
163 level for the Out-Of-Memory killer for
164 executed processes. Takes an integer
165 between -1000 (to disable OOM killing
166 for this process) and 1000 (to make
167 killing of this process under memory
168 pressure very likely). See <ulink
169 url="https://www.kernel.org/doc/Documentation/filesystems/proc.txt">proc.txt</ulink>
170 for details.</para></listitem>
174 <term><varname>IOSchedulingClass=</varname></term>
176 <listitem><para>Sets the IO scheduling
177 class for executed processes. Takes an
178 integer between 0 and 3 or one of the
179 strings <option>none</option>,
180 <option>realtime</option>,
181 <option>best-effort</option> or
182 <option>idle</option>. See
183 <citerefentry><refentrytitle>ioprio_set</refentrytitle><manvolnum>2</manvolnum></citerefentry>
184 for details.</para></listitem>
188 <term><varname>IOSchedulingPriority=</varname></term>
190 <listitem><para>Sets the IO scheduling
191 priority for executed processes. Takes
192 an integer between 0 (highest
193 priority) and 7 (lowest priority). The
194 available priorities depend on the
195 selected IO scheduling class (see
197 <citerefentry><refentrytitle>ioprio_set</refentrytitle><manvolnum>2</manvolnum></citerefentry>
198 for details.</para></listitem>
202 <term><varname>CPUSchedulingPolicy=</varname></term>
204 <listitem><para>Sets the CPU
205 scheduling policy for executed
206 processes. Takes one of
207 <option>other</option>,
208 <option>batch</option>,
209 <option>idle</option>,
210 <option>fifo</option> or
211 <option>rr</option>. See
212 <citerefentry><refentrytitle>sched_setscheduler</refentrytitle><manvolnum>2</manvolnum></citerefentry>
213 for details.</para></listitem>
217 <term><varname>CPUSchedulingPriority=</varname></term>
219 <listitem><para>Sets the CPU
220 scheduling priority for executed
221 processes. The available priority
222 range depends on the selected CPU
223 scheduling policy (see above). For
224 real-time scheduling policies an
225 integer between 1 (lowest priority)
226 and 99 (highest priority) can be used.
227 See <citerefentry><refentrytitle>sched_setscheduler</refentrytitle><manvolnum>2</manvolnum></citerefentry>
233 <term><varname>CPUSchedulingResetOnFork=</varname></term>
235 <listitem><para>Takes a boolean
236 argument. If true, elevated CPU
237 scheduling priorities and policies
238 will be reset when the executed
239 processes fork, and can hence not leak
240 into child processes. See
241 <citerefentry><refentrytitle>sched_setscheduler</refentrytitle><manvolnum>2</manvolnum></citerefentry>
242 for details. Defaults to false.</para></listitem>
246 <term><varname>CPUAffinity=</varname></term>
248 <listitem><para>Controls the CPU
249 affinity of the executed
250 processes. Takes a space-separated
251 list of CPU indices. This option may
252 be specified more than once in which
253 case the specificed CPU affinity masks
254 are merged. If the empty string is
255 assigned, the mask is reset, all
256 assignments prior to this will have no
258 <citerefentry><refentrytitle>sched_setaffinity</refentrytitle><manvolnum>2</manvolnum></citerefentry>
259 for details.</para></listitem>
263 <term><varname>UMask=</varname></term>
265 <listitem><para>Controls the file mode
266 creation mask. Takes an access mode in
268 <citerefentry><refentrytitle>umask</refentrytitle><manvolnum>2</manvolnum></citerefentry>
269 for details. Defaults to
270 0022.</para></listitem>
274 <term><varname>Environment=</varname></term>
276 <listitem><para>Sets environment
277 variables for executed
278 processes. Takes a space-separated
279 list of variable assignments. This
280 option may be specified more than once
281 in which case all listed variables
282 will be set. If the same variable is
283 set twice, the later setting will
284 override the earlier setting. If the
285 empty string is assigned to this
286 option, the list of environment
287 variables is reset, all prior
288 assignments have no effect.
289 Variable expansion is not performed
290 inside the strings, however, specifier
291 expansion is possible. The $ character has
293 If you need to assign a value containing spaces
294 to a variable, use double quotes (")
295 for the assignment.</para>
298 <programlisting>Environment="VAR1=word1 word2" VAR2=word3 "VAR3=$word 5 6"</programlisting>
299 gives three variables <literal>VAR1</literal>,
300 <literal>VAR2</literal>, <literal>VAR3</literal>
301 with the values <literal>word1 word2</literal>,
302 <literal>word3</literal>, <literal>$word 5 6</literal>.
307 <citerefentry><refentrytitle>environ</refentrytitle><manvolnum>7</manvolnum></citerefentry>
308 for details about environment variables.</para></listitem>
311 <term><varname>EnvironmentFile=</varname></term>
312 <listitem><para>Similar to
313 <varname>Environment=</varname> but
314 reads the environment variables from a
315 text file. The text file should
316 contain new-line-separated variable
317 assignments. Empty lines and lines
318 starting with ; or # will be ignored,
319 which may be used for commenting. A line
320 ending with a backslash will be concatenated
321 with the following one, allowing multiline variable
322 definitions. The parser strips leading
323 and trailing whitespace from the values
324 of assignments, unless you use
325 double quotes (").</para>
327 <para>The argument passed should be an
328 absolute filename or wildcard
329 expression, optionally prefixed with
330 <literal>-</literal>, which indicates
331 that if the file does not exist, it
332 will not be read and no error or warning
333 message is logged. This option may be
334 specified more than once in which case
335 all specified files are read. If the
336 empty string is assigned to this
337 option, the list of file to read is
338 reset, all prior assignments have no
341 <para>The files listed with this
342 directive will be read shortly before
343 the process is executed. Settings from
344 these files override settings made
346 <varname>Environment=</varname>. If
347 the same variable is set twice from
348 these files, the files will be read in
349 the order they are specified and the
350 later setting will override the
351 earlier setting.</para></listitem>
355 <term><varname>StandardInput=</varname></term>
356 <listitem><para>Controls where file
357 descriptor 0 (STDIN) of the executed
358 processes is connected to. Takes one
359 of <option>null</option>,
360 <option>tty</option>,
361 <option>tty-force</option>,
362 <option>tty-fail</option> or
363 <option>socket</option>. If
364 <option>null</option> is selected,
365 standard input will be connected to
366 <filename>/dev/null</filename>,
367 i.e. all read attempts by the process
368 will result in immediate EOF. If
369 <option>tty</option> is selected,
370 standard input is connected to a TTY
372 <varname>TTYPath=</varname>, see
373 below) and the executed process
374 becomes the controlling process of the
375 terminal. If the terminal is already
376 being controlled by another process, the
377 executed process waits until the current
378 controlling process releases the
380 <option>tty-force</option>
381 is similar to <option>tty</option>,
382 but the executed process is forcefully
383 and immediately made the controlling
384 process of the terminal, potentially
385 removing previous controlling
387 terminal. <option>tty-fail</option> is
388 similar to <option>tty</option> but if
389 the terminal already has a controlling
390 process start-up of the executed
392 <option>socket</option> option is only
393 valid in socket-activated services,
394 and only when the socket configuration
396 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>
397 for details) specifies a single socket
398 only. If this option is set, standard
399 input will be connected to the socket
400 the service was activated from, which
401 is primarily useful for compatibility
402 with daemons designed for use with the
404 <citerefentry><refentrytitle>inetd</refentrytitle><manvolnum>8</manvolnum></citerefentry>
405 daemon. This setting defaults to
406 <option>null</option>.</para></listitem>
409 <term><varname>StandardOutput=</varname></term>
410 <listitem><para>Controls where file
411 descriptor 1 (STDOUT) of the executed
412 processes is connected to. Takes one
413 of <option>inherit</option>,
414 <option>null</option>,
415 <option>tty</option>,
416 <option>syslog</option>,
417 <option>kmsg</option>,
418 <option>journal</option>,
419 <option>syslog+console</option>,
420 <option>kmsg+console</option>,
421 <option>journal+console</option> or
422 <option>socket</option>. If set to
423 <option>inherit</option>, the file
424 descriptor of standard input is
425 duplicated for standard output. If set
426 to <option>null</option>, standard
427 output will be connected to
428 <filename>/dev/null</filename>,
429 i.e. everything written to it will be
430 lost. If set to <option>tty</option>,
431 standard output will be connected to a
432 tty (as configured via
433 <varname>TTYPath=</varname>, see
434 below). If the TTY is used for output
435 only, the executed process will not
436 become the controlling process of the
437 terminal, and will not fail or wait
438 for other processes to release the
439 terminal. <option>syslog</option>
440 connects standard output to the
441 <citerefentry><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>
443 service. <option>kmsg</option>
444 connects it with the kernel log buffer
445 which is accessible via
446 <citerefentry><refentrytitle>dmesg</refentrytitle><manvolnum>1</manvolnum></citerefentry>. <option>journal</option>
447 connects it with the journal which is
449 <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
450 (Note that everything that is written
451 to syslog or kmsg is implicitly stored
452 in the journal as well, those options
453 are hence supersets of this
454 one). <option>syslog+console</option>,
455 <option>journal+console</option> and
456 <option>kmsg+console</option> work
457 similarly but copy the output to the
459 well. <option>socket</option> connects
460 standard output to a socket from
461 socket activation, semantics are
462 similar to the respective option of
463 <varname>StandardInput=</varname>.
464 This setting defaults to the value set
466 <option>DefaultStandardOutput=</option>
468 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
470 <option>journal</option>.</para></listitem>
473 <term><varname>StandardError=</varname></term>
474 <listitem><para>Controls where file
475 descriptor 2 (STDERR) of the
476 executed processes is connected to.
477 The available options are identical to
479 <varname>StandardOutput=</varname>,
480 with one exception: if set to
481 <option>inherit</option> the file
482 descriptor used for standard output is
483 duplicated for standard error. This
484 setting defaults to the value set with
485 <option>DefaultStandardError=</option>
487 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
489 <option>inherit</option>.</para></listitem>
492 <term><varname>TTYPath=</varname></term>
493 <listitem><para>Sets the terminal
494 device node to use if standard input, output,
495 or error are connected to a
496 TTY (see above). Defaults to
497 <filename>/dev/console</filename>.</para></listitem>
500 <term><varname>TTYReset=</varname></term>
501 <listitem><para>Reset the terminal
502 device specified with
503 <varname>TTYPath=</varname> before and
504 after execution. Defaults to
505 <literal>no</literal>.</para></listitem>
508 <term><varname>TTYVHangup=</varname></term>
509 <listitem><para>Disconnect all clients
510 which have opened the terminal device
512 <varname>TTYPath=</varname>
513 before and after execution. Defaults
515 <literal>no</literal>.</para></listitem>
518 <term><varname>TTYVTDisallocate=</varname></term>
519 <listitem><para>If the terminal
520 device specified with
521 <varname>TTYPath=</varname> is a
522 virtual console terminal, try to
523 deallocate the TTY before and after
524 execution. This ensures that the
525 screen and scrollback buffer is
527 <literal>no</literal>.</para></listitem>
530 <term><varname>SyslogIdentifier=</varname></term>
531 <listitem><para>Sets the process name
532 to prefix log lines sent to syslog or
533 the kernel log buffer with. If not set,
534 defaults to the process name of the
535 executed process. This option is only
537 <varname>StandardOutput=</varname> or
538 <varname>StandardError=</varname> are
539 set to <option>syslog</option> or
540 <option>kmsg</option>.</para></listitem>
543 <term><varname>SyslogFacility=</varname></term>
544 <listitem><para>Sets the syslog
545 facility to use when logging to
546 syslog. One of <option>kern</option>,
547 <option>user</option>,
548 <option>mail</option>,
549 <option>daemon</option>,
550 <option>auth</option>,
551 <option>syslog</option>,
552 <option>lpr</option>,
553 <option>news</option>,
554 <option>uucp</option>,
555 <option>cron</option>,
556 <option>authpriv</option>,
557 <option>ftp</option>,
558 <option>local0</option>,
559 <option>local1</option>,
560 <option>local2</option>,
561 <option>local3</option>,
562 <option>local4</option>,
563 <option>local5</option>,
564 <option>local6</option> or
565 <option>local7</option>. See
566 <citerefentry><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>
567 for details. This option is only
569 <varname>StandardOutput=</varname> or
570 <varname>StandardError=</varname> are
571 set to <option>syslog</option>.
573 <option>daemon</option>.</para></listitem>
576 <term><varname>SyslogLevel=</varname></term>
577 <listitem><para>Default syslog level
578 to use when logging to syslog or the
579 kernel log buffer. One of
580 <option>emerg</option>,
581 <option>alert</option>,
582 <option>crit</option>,
583 <option>err</option>,
584 <option>warning</option>,
585 <option>notice</option>,
586 <option>info</option>,
587 <option>debug</option>. See
588 <citerefentry><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>
589 for details. This option is only
591 <varname>StandardOutput=</varname> or
592 <varname>StandardError=</varname> are
593 set to <option>syslog</option> or
594 <option>kmsg</option>. Note that
595 individual lines output by the daemon
596 might be prefixed with a different log
597 level which can be used to override
598 the default log level specified
599 here. The interpretation of these
600 prefixes may be disabled with
601 <varname>SyslogLevelPrefix=</varname>,
602 see below. For details see
603 <citerefentry><refentrytitle>sd-daemon</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
606 <option>info</option>.</para></listitem>
610 <term><varname>SyslogLevelPrefix=</varname></term>
611 <listitem><para>Takes a boolean
612 argument. If true and
613 <varname>StandardOutput=</varname> or
614 <varname>StandardError=</varname> are
615 set to <option>syslog</option>,
616 <option>kmsg</option> or
617 <option>journal</option>, log lines
618 written by the executed process that
619 are prefixed with a log level will be
620 passed on to syslog with this log
621 level set but the prefix removed. If
622 set to false, the interpretation of
623 these prefixes is disabled and the
624 logged lines are passed on as-is. For
625 details about this prefixing see
626 <citerefentry><refentrytitle>sd-daemon</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
627 Defaults to true.</para></listitem>
631 <term><varname>TimerSlackNSec=</varname></term>
632 <listitem><para>Sets the timer slack
633 in nanoseconds for the executed
634 processes. The timer slack controls
635 the accuracy of wake-ups triggered by
637 <citerefentry><refentrytitle>prctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
638 for more information. Note that in
639 contrast to most other time span
640 definitions this parameter takes an
641 integer value in nano-seconds if no
642 unit is specified. The usual time
644 too.</para></listitem>
648 <term><varname>LimitCPU=</varname></term>
649 <term><varname>LimitFSIZE=</varname></term>
650 <term><varname>LimitDATA=</varname></term>
651 <term><varname>LimitSTACK=</varname></term>
652 <term><varname>LimitCORE=</varname></term>
653 <term><varname>LimitRSS=</varname></term>
654 <term><varname>LimitNOFILE=</varname></term>
655 <term><varname>LimitAS=</varname></term>
656 <term><varname>LimitNPROC=</varname></term>
657 <term><varname>LimitMEMLOCK=</varname></term>
658 <term><varname>LimitLOCKS=</varname></term>
659 <term><varname>LimitSIGPENDING=</varname></term>
660 <term><varname>LimitMSGQUEUE=</varname></term>
661 <term><varname>LimitNICE=</varname></term>
662 <term><varname>LimitRTPRIO=</varname></term>
663 <term><varname>LimitRTTIME=</varname></term>
664 <listitem><para>These settings control
665 various resource limits for executed
667 <citerefentry><refentrytitle>setrlimit</refentrytitle><manvolnum>2</manvolnum></citerefentry>
668 for details. Use the string
669 <varname>infinity</varname> to
670 configure no limit on a specific
671 resource.</para></listitem>
675 <term><varname>PAMName=</varname></term>
676 <listitem><para>Sets the PAM service
677 name to set up a session as. If set,
678 the executed process will be
679 registered as a PAM session under the
680 specified service name. This is only
681 useful in conjunction with the
682 <varname>User=</varname> setting. If
683 not set, no PAM session will be opened
684 for the executed processes. See
685 <citerefentry><refentrytitle>pam</refentrytitle><manvolnum>8</manvolnum></citerefentry>
686 for details.</para></listitem>
690 <term><varname>CapabilityBoundingSet=</varname></term>
692 <listitem><para>Controls which
693 capabilities to include in the
694 capability bounding set for the
695 executed process. See
696 <citerefentry><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>
697 for details. Takes a whitespace-separated
698 list of capability names as read by
699 <citerefentry><refentrytitle>cap_from_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
700 e.g. <constant>CAP_SYS_ADMIN</constant>,
701 <constant>CAP_DAC_OVERRIDE</constant>,
702 <constant>CAP_SYS_PTRACE</constant>.
703 Capabilities listed will be included
704 in the bounding set, all others are
705 removed. If the list of capabilities
706 is prefixed with <literal>~</literal>,
707 all but the listed capabilities will
708 be included, the effect of the
709 assignment inverted. Note that this
710 option also affects the respective
711 capabilities in the effective,
712 permitted and inheritable capability
714 <varname>Capabilities=</varname>
715 does. If this option is not used, the
716 capability bounding set is not
717 modified on process execution, hence
718 no limits on the capabilities of the
719 process are enforced. This option may
720 appear more than once in which case
721 the bounding sets are merged. If the
722 empty string is assigned to this
723 option, the bounding set is reset to
724 the empty capability set, and all
725 prior settings have no effect. If set
726 to <literal>~</literal> (without any
727 further argument), the bounding set is
728 reset to the full set of available
729 capabilities, also undoing any
730 previous settings.</para></listitem>
734 <term><varname>SecureBits=</varname></term>
735 <listitem><para>Controls the secure
736 bits set for the executed process. See
737 <citerefentry><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>
738 for details. Takes a list of strings:
739 <option>keep-caps</option>,
740 <option>keep-caps-locked</option>,
741 <option>no-setuid-fixup</option>,
742 <option>no-setuid-fixup-locked</option>,
743 <option>noroot</option> and/or
744 <option>noroot-locked</option>. This
745 option may appear more than once in
746 which case the secure bits are
747 ORed. If the empty string is assigned
748 to this option, the bits are reset to
753 <term><varname>Capabilities=</varname></term>
754 <listitem><para>Controls the
755 <citerefentry><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>
756 set for the executed process. Take a
757 capability string describing the
758 effective, permitted and inherited
759 capability sets as documented in
760 <citerefentry><refentrytitle>cap_from_text</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
761 Note that these capability sets are
762 usually influenced by the capabilities
763 attached to the executed file. Due to
765 <varname>CapabilityBoundingSet=</varname>
766 is probably the much more useful
767 setting.</para></listitem>
771 <term><varname>ReadWriteDirectories=</varname></term>
772 <term><varname>ReadOnlyDirectories=</varname></term>
773 <term><varname>InaccessibleDirectories=</varname></term>
775 <listitem><para>Sets up a new
776 file system namespace for executed
777 processes. These options may be used
778 to limit access a process might have
779 to the main file system
780 hierarchy. Each setting takes a
781 space-separated list of absolute
782 directory paths. Directories listed in
783 <varname>ReadWriteDirectories=</varname>
784 are accessible from within the
785 namespace with the same access rights
786 as from outside. Directories listed in
787 <varname>ReadOnlyDirectories=</varname>
788 are accessible for reading only,
789 writing will be refused even if the
790 usual file access controls would
791 permit this. Directories listed in
792 <varname>InaccessibleDirectories=</varname>
793 will be made inaccessible for
794 processes inside the namespace. Note
795 that restricting access with these
796 options does not extend to submounts
797 of a directory. You must list
798 submounts separately in these settings
799 to ensure the same limited
800 access. These options may be specified
801 more than once in which case all
802 directories listed will have limited
803 access from within the namespace. If
804 the empty string is assigned to this
805 option, the specific list is reset, and
806 all prior assignments have no
809 <varname>ReadOnlyDirectories=</varname>
811 <varname>InaccessibleDirectories=</varname>
813 <literal>-</literal>, in which case
814 they will be ignored when they do not
815 exist. Note that using this
816 setting will disconnect propagation of
817 mounts from the service to the host
818 (propagation in the opposite direction
819 continues to work). This means that
820 this setting may not be used for
821 services which shall be able to
822 install mount points in the main mount
823 namespace.</para></listitem>
827 <term><varname>PrivateTmp=</varname></term>
829 <listitem><para>Takes a boolean
830 argument. If true, sets up a new file
831 system namespace for the executed
832 processes and mounts private
833 <filename>/tmp</filename> and
834 <filename>/var/tmp</filename>
835 directories inside it that is not
836 shared by processes outside of the
837 namespace. This is useful to secure
838 access to temporary files of the
839 process, but makes sharing between
841 <filename>/tmp</filename> or
842 <filename>/var/tmp</filename>
843 impossible. If this is enabled all
844 temporary files created by a service
845 in these directories will be removed
846 after the service is stopped. Defaults
847 to false. It is possible to run two or
848 more units within the same private
849 <filename>/tmp</filename> and
850 <filename>/var/tmp</filename>
851 namespace by using the
852 <varname>JoinsNamespaceOf=</varname>
854 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
855 for details. Note that using this
856 setting will disconnect propagation of
857 mounts from the service to the host
858 (propagation in the opposite direction
859 continues to work). This means that
860 this setting may not be used for
861 services which shall be able to install
862 mount points in the main mount
863 namespace.</para></listitem>
867 <term><varname>PrivateDevices=</varname></term>
869 <listitem><para>Takes a boolean
870 argument. If true, sets up a new /dev
871 namespace for the executed processes
872 and only adds API pseudo devices such
873 as <filename>/dev/null</filename>,
874 <filename>/dev/zero</filename> or
875 <filename>/dev/random</filename> (as
876 well as the pseudo TTY subsystem) to
877 it, but no physical devices such as
878 <filename>/dev/sda</filename>. This is
879 useful to securely turn off physical
880 device access by the executed
881 process. Defaults to false. Enabling
882 this option will also remove
883 <constant>CAP_MKNOD</constant> from
884 the capability bounding set for the
885 unit (see above), and set
886 <varname>DevicePolicy=closed</varname>
888 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
889 for details). Note that using this
890 setting will disconnect propagation of
891 mounts from the service to the host
892 (propagation in the opposite direction
893 continues to work). This means that
894 this setting may not be used for
895 services which shall be able to
896 install mount points in the main mount
897 namespace.</para></listitem>
901 <term><varname>PrivateNetwork=</varname></term>
903 <listitem><para>Takes a boolean
904 argument. If true, sets up a new
905 network namespace for the executed
906 processes and configures only the
907 loopback network device
908 <literal>lo</literal> inside it. No
909 other network devices will be
910 available to the executed process.
911 This is useful to securely turn off
912 network access by the executed
913 process. Defaults to false. It is
914 possible to run two or more units
915 within the same private network
916 namespace by using the
917 <varname>JoinsNamespaceOf=</varname>
919 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
920 for details. Note that this option
921 will disconnect all socket families
922 from the host, this includes
923 AF_NETLINK and AF_UNIX. The latter has
924 the effect that AF_UNIX sockets in the
925 abstract socket namespace will become
926 unavailable to the processes (however,
927 those located in the file system will
929 accessible).</para></listitem>
933 <term><varname>MountFlags=</varname></term>
935 <listitem><para>Takes a mount
937 <option>shared</option>,
938 <option>slave</option> or
939 <option>private</option>, which
940 control whether mounts in the file
941 system namespace set up for this
942 unit's processes will receive or
943 propagate mounts or unmounts. See
944 <citerefentry><refentrytitle>mount</refentrytitle><manvolnum>2</manvolnum></citerefentry>
945 for details. Defaults to
946 <option>shared</option>. Use
947 <option>shared</option> to ensure that
948 mounts and unmounts are propagated
949 from the host to the container and
950 vice versa. Use <option>slave</option>
951 to run processes so that none of their
952 mounts and unmounts will propagate to
953 the host. Use <option>private</option>
954 to also ensure that no mounts and
955 unmounts from the host will propagate
956 into the unit processes'
958 <option>slave</option> means that file
959 systems mounted on the host might stay
960 mounted continously in the unit's
961 namespace, and thus keep the device
962 busy. Note that the file system
963 namespace related options
964 (<varname>PrivateTmp=</varname>,
965 <varname>PrivateDevices=</varname>,
966 <varname>ReadOnlyDirectories=</varname>,
967 <varname>InaccessibleDirectories=</varname>
969 <varname>ReadWriteDirectories=</varname>)
970 require that mount and unmount
971 propagation from the unit's file
972 system namespace is disabled, and
974 <option>shared</option> to
975 <option>slave</option>.
980 <term><varname>UtmpIdentifier=</varname></term>
982 <listitem><para>Takes a four
983 character identifier string for an
984 utmp/wtmp entry for this service. This
985 should only be set for services such
986 as <command>getty</command>
987 implementations where utmp/wtmp
988 entries must be created and cleared
989 before and after execution. If the
990 configured string is longer than four
991 characters, it is truncated and the
992 terminal four characters are
993 used. This setting interprets %I style
994 string replacements. This setting is
995 unset by default, i.e. no utmp/wtmp
996 entries are created or cleaned up for
997 this service.</para></listitem>
1001 <term><varname>SELinuxContext=</varname></term>
1003 <listitem><para>Set the SELinux
1004 security context of the executed
1005 process. If set, this will override
1006 the automated domain
1007 transition. However, the policy still
1008 needs to autorize the transition. This
1009 directive is ignored if SELinux is
1010 disabled. If prefixed by
1011 <literal>-</literal>, all errors will
1013 <citerefentry><refentrytitle>setexeccon</refentrytitle><manvolnum>3</manvolnum></citerefentry>
1014 for details.</para></listitem>
1018 <term><varname>AppArmorProfile=</varname></term>
1020 <listitem><para>Take a profile name as argument.
1021 The process executed by the unit will switch to
1022 this profile when started. Profiles must already
1023 be loaded in the kernel, or the unit will fail.
1024 This result in a non operation if AppArmor is not
1025 enabled. If prefixed by <literal>-</literal>, all errors
1031 <term><varname>IgnoreSIGPIPE=</varname></term>
1033 <listitem><para>Takes a boolean
1034 argument. If true, causes <constant>SIGPIPE</constant> to be
1035 ignored in the executed
1036 process. Defaults to true because
1037 <constant>SIGPIPE</constant> generally is useful only in
1038 shell pipelines.</para></listitem>
1042 <term><varname>NoNewPrivileges=</varname></term>
1044 <listitem><para>Takes a boolean
1045 argument. If true, ensures that the
1046 service process and all its children
1047 can never gain new privileges. This
1048 option is more powerful than the respective
1049 secure bits flags (see above), as it
1050 also prohibits UID changes of any
1051 kind. This is the simplest, most
1052 effective way to ensure that a process
1053 and its children can never elevate
1054 privileges again.</para></listitem>
1058 <term><varname>SystemCallFilter=</varname></term>
1060 <listitem><para>Takes a
1061 space-separated list of system call
1062 names. If this setting is used, all
1063 system calls executed by the unit
1064 processes except for the listed ones
1065 will result in immediate process
1066 termination with the
1067 <constant>SIGSYS</constant> signal
1068 (whitelisting). If the first character
1069 of the list is <literal>~</literal>,
1070 the effect is inverted: only the
1071 listed system calls will result in
1072 immediate process termination
1073 (blacklisting). If running in user
1074 mode and this option is used,
1075 <varname>NoNewPrivileges=yes</varname>
1076 is implied. This feature makes use of the
1077 Secure Computing Mode 2 interfaces of
1078 the kernel ('seccomp filtering') and
1079 is useful for enforcing a minimal
1080 sandboxing environment. Note that the
1081 <function>execve</function>,
1082 <function>rt_sigreturn</function>,
1083 <function>sigreturn</function>,
1084 <function>exit_group</function>,
1085 <function>exit</function> system calls
1086 are implicitly whitelisted and do not
1087 need to be listed explicitly. This
1088 option may be specified more than once
1089 in which case the filter masks are
1090 merged. If the empty string is
1091 assigned, the filter is reset, all
1092 prior assignments will have no
1095 <para>If you specify both types of
1096 this option (i.e. whitelisting and
1097 blacklisting), the first encountered
1098 will take precedence and will dictate
1099 the default action (termination or
1100 approval of a system call). Then the
1101 next occurrences of this option will
1102 add or delete the listed system calls
1103 from the set of the filtered system
1104 calls, depending of its type and the
1105 default action. (For example, if you have started
1106 with a whitelisting of
1107 <function>read</function> and
1108 <function>write</function>, and right
1109 after it add a blacklisting of
1110 <function>write</function>, then
1111 <function>write</function> will be
1112 removed from the set.)
1117 <term><varname>SystemCallErrorNumber=</varname></term>
1119 <listitem><para>Takes an
1120 <literal>errno</literal> error number
1121 name to return when the system call
1122 filter configured with
1123 <varname>SystemCallFilter=</varname>
1124 is triggered, instead of terminating
1125 the process immediately. Takes an
1127 <constant>EPERM</constant>,
1128 <constant>EACCES</constant> or
1129 <constant>EUCLEAN</constant>. When this
1130 setting is not used, or when the empty
1131 string is assigned, the process will be
1132 terminated immediately when the filter
1133 is triggered.</para></listitem>
1137 <term><varname>SystemCallArchitectures=</varname></term>
1139 <listitem><para>Takes a space
1140 separated list of architecture
1141 identifiers to include in the system
1142 call filter. The known architecture
1144 <constant>x86</constant>,
1145 <constant>x86-64</constant>,
1146 <constant>x32</constant>,
1147 <constant>arm</constant> as well as
1148 the special identifier
1149 <constant>native</constant>. Only
1150 system calls of the specified
1151 architectures will be permitted to
1152 processes of this unit. This is an
1153 effective way to disable compatibility
1154 with non-native architectures for
1155 processes, for example to prohibit
1156 execution of 32-bit x86 binaries on
1157 64-bit x86-64 systems. The special
1158 <constant>native</constant> identifier
1159 implicitly maps to the native
1160 architecture of the system (or more
1161 strictly: to the architecture the
1162 system manager is compiled for). If
1163 running in user mode and this option
1165 <varname>NoNewPrivileges=yes</varname>
1166 is implied. Note that setting this
1167 option to a non-empty list implies
1168 that <constant>native</constant> is
1169 included too. By default, this option
1170 is set to the empty list, i.e. no
1171 architecture system call filtering is
1172 applied.</para></listitem>
1176 <term><varname>RestrictAddressFamilies=</varname></term>
1178 <listitem><para>Restricts the set of
1179 socket address families accessible to
1180 the processes of this unit. Takes a
1181 space-separated list of address family
1182 names to whitelist, such as
1183 <constant>AF_UNIX</constant>,
1184 <constant>AF_INET</constant> or
1185 <constant>AF_INET6</constant>. When
1186 prefixed with <constant>~</constant>
1187 the listed address families will be
1188 applied as blacklist, otherwise as
1189 whitelist. Note that this restricts
1191 <citerefentry><refentrytitle>socket</refentrytitle><manvolnum>2</manvolnum></citerefentry>
1192 system call only. Sockets passed into
1193 the process by other means (for
1194 example, by using socket activation
1195 with socket units, see
1196 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>)
1197 are unaffected. Also, sockets created
1198 with <function>socketpair()</function>
1199 (which creates connected AF_UNIX
1200 sockets only) are unaffected. Note
1201 that this option has no effect on
1202 32bit x86 and is ignored (but works
1203 correctly on x86-64). If running in user
1204 mode and this option is used,
1205 <varname>NoNewPrivileges=yes</varname>
1206 is implied. By default no
1207 restriction applies, all address
1208 families are accessible to
1209 processes. If assigned the empty
1210 string any previous list changes are
1213 <para>Use this option to limit
1214 exposure of processes to remote
1215 systems, in particular via exotic
1216 network protocols. Note that in most
1218 <constant>AF_UNIX</constant> address
1219 family should be included in the
1220 configured whitelist as it is
1221 frequently used for local
1222 communication, including for
1223 <citerefentry><refentrytitle>syslog</refentrytitle><manvolnum>2</manvolnum></citerefentry>
1224 logging.</para></listitem>
1228 <term><varname>Personality=</varname></term>
1230 <listitem><para>Controls which
1232 <citerefentry><refentrytitle>uname</refentrytitle><manvolnum>2</manvolnum></citerefentry>
1233 shall report, when invoked by unit
1234 processes. Takes one of
1235 <constant>x86</constant> and
1236 <constant>x86-64</constant>. This is
1237 useful when running 32bit services on
1238 a 64bit host system. If not specified
1239 the personality is left unmodified and
1240 thus reflects the personality of the
1242 kernel.</para></listitem>
1246 <term><varname>RuntimeDirectory=</varname></term>
1247 <term><varname>RuntimeDirectoryMode=</varname></term>
1249 <listitem><para>Takes a list of
1250 directory names. If set one or more
1251 directories by the specified names
1252 will be created below
1253 <filename>/run</filename> (for system
1255 <varname>$XDG_RUNTIME_DIR</varname>
1256 (for user services) when the unit is
1257 started and removed when the unit is
1258 stopped. The directories will have the
1259 access mode specified in
1260 <varname>RuntimeDirectoryMode=</varname>,
1261 and will be owned by the user and
1263 <varname>User=</varname> and
1264 <varname>Group=</varname>. Use this to
1265 manage one or more runtime directories
1266 of the unit and bind their lifetime to
1267 the daemon runtime. The specified
1268 directory names must be relative, and
1270 <literal>/</literal>, i.e. must refer
1271 to simple directories to create or
1272 remove. This is particularly useful
1273 for unpriviliges daemons that cannot
1274 create runtime directories in
1275 <filename>/run</filename> due to lack
1276 of privileges, and to make sure the
1277 runtime directory is cleaned up
1278 automatically after use. For runtime
1279 directories that require more complex
1280 or different configuration or lifetime
1281 guarantees, please consider using
1282 <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para></listitem>
1289 <title>Environment variables in spawned processes</title>
1291 <para>Processes started by the system are executed in
1292 a clean environment in which select variables
1293 listed below are set. System processes started by systemd
1294 do not inherit variables from PID 1, but processes
1295 started by user systemd instances inherit all
1296 environment variables from the user systemd instance.
1299 <variablelist class='environment-variables'>
1301 <term><varname>$PATH</varname></term>
1303 <listitem><para>Colon-separated list
1304 of directiories to use when launching
1305 executables. Systemd uses a fixed
1307 <filename>/usr/local/sbin</filename>:<filename>/usr/local/bin</filename>:<filename>/usr/sbin</filename>:<filename>/usr/bin</filename>:<filename>/sbin</filename>:<filename>/bin</filename>.
1312 <term><varname>$LANG</varname></term>
1314 <listitem><para>Locale. Can be set in
1315 <citerefentry><refentrytitle>locale.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
1316 or on the kernel command line (see
1317 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
1319 <citerefentry><refentrytitle>kernel-command-line</refentrytitle><manvolnum>7</manvolnum></citerefentry>).
1324 <term><varname>$USER</varname></term>
1325 <term><varname>$LOGNAME</varname></term>
1326 <term><varname>$HOME</varname></term>
1327 <term><varname>$SHELL</varname></term>
1329 <listitem><para>User name (twice), home
1330 directory, and the login shell.
1331 The variables are set for the units that
1332 have <varname>User=</varname> set,
1334 <command>systemd</command> instances.
1336 <citerefentry><refentrytitle>passwd</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
1341 <term><varname>$XDG_RUNTIME_DIR</varname></term>
1343 <listitem><para>The directory for volatile
1344 state. Set for the user <command>systemd</command>
1345 instance, and also in user sessions.
1347 <citerefentry><refentrytitle>pam_systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
1352 <term><varname>$XDG_SESSION_ID</varname></term>
1353 <term><varname>$XDG_SEAT</varname></term>
1354 <term><varname>$XDG_VTNR</varname></term>
1356 <listitem><para>The identifier of the
1357 session, the seat name, and
1358 virtual terminal of the session. Set
1360 <citerefentry><refentrytitle>pam_systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry>
1362 <varname>$XDG_SEAT</varname> and
1363 <varname>$XDG_VTNR</varname> will
1364 only be set when attached to a seat and a
1365 tty.</para></listitem>
1369 <term><varname>$MAINPID</varname></term>
1371 <listitem><para>The PID of the units
1372 main process if it is known. This is
1373 only set for control processes as
1375 <varname>ExecReload=</varname> and
1376 similar. </para></listitem>
1380 <term><varname>$MANAGERPID</varname></term>
1382 <listitem><para>The PID of the user
1383 <command>systemd</command> instance,
1384 set for processes spawned by it.
1389 <term><varname>$LISTEN_FDS</varname></term>
1390 <term><varname>$LISTEN_PID</varname></term>
1392 <listitem><para>Information about file
1393 descriptors passed to a service for
1394 socket activation. See
1395 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
1400 <term><varname>$TERM</varname></term>
1402 <listitem><para>Terminal type, set
1403 only for units connected to a terminal
1404 (<varname>StandardInput=tty</varname>,
1405 <varname>StandardOutput=tty</varname>,
1407 <varname>StandardError=tty</varname>).
1409 <citerefentry><refentrytitle>termcap</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
1414 <para>Additional variables may be configured by the
1415 following means: for processes spawned in specific
1416 units, use the <varname>Environment=</varname> and
1417 <varname>EnvironmentFile=</varname> options above; to
1418 specify variables globally, use
1419 <varname>DefaultEnvironment=</varname> (see
1420 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>)
1421 or the kernel option
1422 <varname>systemd.setenv=</varname> (see
1423 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>). Additional
1424 variables may also be set through PAM,
1425 c.f. <citerefentry><refentrytitle>pam_env</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
1429 <title>See Also</title>
1431 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1432 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
1433 <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
1434 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1435 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1436 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1437 <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1438 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1439 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1440 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1441 <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
1442 <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1443 <citerefentry><refentrytitle>exec</refentrytitle><manvolnum>3</manvolnum></citerefentry>