1SYSTEMD.SYNTAX(7) systemd.syntax SYSTEMD.SYNTAX(7)
2
3
4
6 systemd.syntax - General syntax of systemd configuration files
7
9 This page describes the basic principles of configuration files used by
10 systemd(1) and related programs for:
11
12 • systemd unit files, see systemd.unit(5), systemd.service(5),
13 systemd.socket(5), systemd.device(5), systemd.mount(5),
14 systemd.automount(5), systemd.swap(5), systemd.target(5),
15 systemd.path(5), systemd.timer(5), systemd.slice(5),
16 systemd.scope(5), systemd.nspawn(5)
17
18 • link files, see systemd.link(5)
19
20 • netdev and network files, see systemd.netdev(5), systemd.network(5)
21
22 • daemon config files, see systemd-system.conf(5), systemd-
23 user.conf(5), logind.conf(5), journald.conf(5), journal-
24 remote.conf(5), journal-upload.conf(5), systemd-sleep.conf(5),
25 timesyncd.conf(5)
26
27 The syntax is inspired by XDG Desktop Entry Specification[1] .desktop
28 files, which are in turn inspired by Microsoft Windows .ini files.
29
30 Each file is a plain text file divided into sections, with
31 configuration entries in the style key=value. Whitespace immediately
32 before or after the "=" is ignored. Empty lines and lines starting with
33 "#" or ";" are ignored, which may be used for commenting.
34
35 Lines ending in a backslash are concatenated with the following line
36 while reading and the backslash is replaced by a space character. This
37 may be used to wrap long lines. The limit on line length is very large
38 (currently 1 MB), but it is recommended to avoid such long lines and
39 use multiple directives, variable substitution, or other mechanism as
40 appropriate for the given file type. When a comment line or lines
41 follow a line ending with a backslash, the comment block is ignored, so
42 the continued line is concatenated with whatever follows the comment
43 block.
44
45 Example 1.
46
47 [Section A]
48 KeyOne=value 1
49 KeyTwo=value 2
50
51 # a comment
52
53 [Section B]
54 Setting="something" "some thing" "..."
55 KeyTwo=value 2 \
56 value 2 continued
57
58 [Section C]
59 KeyThree=value 3\
60 # this line is ignored
61 ; this line is ignored too
62 value 3 continued
63
64 Boolean arguments used in configuration files can be written in various
65 formats. For positive settings the strings 1, yes, true and on are
66 equivalent. For negative settings, the strings 0, no, false and off are
67 equivalent.
68
69 Time span values encoded in configuration files can be written in
70 various formats. A stand-alone number specifies a time in seconds. If
71 suffixed with a time unit, the unit is honored. A concatenation of
72 multiple values with units is supported, in which case the values are
73 added up. Example: "50" refers to 50 seconds; "2min 200ms" refers to 2
74 minutes and 200 milliseconds, i.e. 120200 ms. The following time units
75 are understood: "s", "min", "h", "d", "w", "ms", "us". For details see
76 systemd.time(7).
77
78 Various settings are allowed to be specified more than once, in which
79 case the interpretation depends on the setting. Often, multiple
80 settings form a list, and setting to an empty value "resets", which
81 means that previous assignments are ignored. When this is allowed, it
82 is mentioned in the description of the setting. Note that using
83 multiple assignments to the same value makes the file incompatible with
84 parsers for the XDG .desktop file format.
85
87 For settings where quoting is allowed, the following general rules
88 apply: double quotes ("...") and single quotes ('...') may be used to
89 wrap a whole item (the opening quote may appear only at the beginning
90 or after whitespace that is not quoted, and the closing quote must be
91 followed by whitespace or the end of line), in which case everything
92 until the next matching quote becomes part of the same item. Quotes
93 themselves are removed. C-style escapes are supported. The table below
94 contains the list of known escape patterns. Only escape patterns which
95 match the syntax in the table are allowed; other patterns may be added
96 in the future and unknown patterns will result in a warning. In
97 particular, any backslashes should be doubled. Finally, a trailing
98 backslash ("\") may be used to merge lines, as described above. UTF-8
99 is accepted, and hence typical unicode characters do not need to be
100 escaped.
101
102 Table 1. Supported escapes
103 ┌─────────────┬────────────────────────────┐
104 │Literal │ Actual value │
105 ├─────────────┼────────────────────────────┤
106 │"\a" │ bell │
107 ├─────────────┼────────────────────────────┤
108 │"\b" │ backspace │
109 ├─────────────┼────────────────────────────┤
110 │"\f" │ form feed │
111 ├─────────────┼────────────────────────────┤
112 │"\n" │ newline │
113 ├─────────────┼────────────────────────────┤
114 │"\r" │ carriage return │
115 ├─────────────┼────────────────────────────┤
116 │"\t" │ tab │
117 ├─────────────┼────────────────────────────┤
118 │"\v" │ vertical tab │
119 ├─────────────┼────────────────────────────┤
120 │"\\" │ backslash │
121 ├─────────────┼────────────────────────────┤
122 │"\"" │ double quotation mark │
123 ├─────────────┼────────────────────────────┤
124 │"\'" │ single quotation mark │
125 ├─────────────┼────────────────────────────┤
126 │"\s" │ space │
127 ├─────────────┼────────────────────────────┤
128 │"\xxx" │ character number xx in │
129 │ │ hexadecimal encoding │
130 ├─────────────┼────────────────────────────┤
131 │"\nnn" │ character number nnn in │
132 │ │ octal encoding │
133 ├─────────────┼────────────────────────────┤
134 │"\unnnn" │ unicode code point nnnn in │
135 │ │ hexadecimal encoding │
136 ├─────────────┼────────────────────────────┤
137 │"\Unnnnnnnn" │ unicode code point │
138 │ │ nnnnnnnn in hexadecimal │
139 │ │ encoding │
140 └─────────────┴────────────────────────────┘
141
143 systemd.time(7)
144
146 1. XDG Desktop Entry Specification
147 http://standards.freedesktop.org/desktop-entry-spec/latest/
148
149
150
151systemd 250 SYSTEMD.SYNTAX(7)