SYSTEMD.SYNTAX(7)
๐ systemd.syntax โ the group chat guide to systemd config file syntax โจ
okay bestie, so this is systemd.syntax(7) โ it's the one page that teaches you the general syntax that all the systemd config files share. Think of it as the vibe check that every config file has to pass before it's allowed in the group chat. ๐
๐ธ NAME ๐ธ
systemd.syntax โ the general syntax of systemd configuration files. that's it, that's the name, she's simple and she's iconic. ๐
โจ INTRODUCTION โจ
So systemd(1) and all her related programs use these same basic config file principles. And she's not gatekeeping โ she shares this syntax with a whole friend group. here's who's in it:
- systemd unit files, see
systemd.unit(5),systemd.service(5),systemd.socket(5),systemd.device(5),systemd.mount(5),systemd.automount(5),systemd.swap(5),systemd.target(5),systemd.path(5),systemd.timer(5),systemd.slice(5),systemd.scope(5) - link files, see
systemd.link(5) - netdev and network files, see
systemd.netdev(5),systemd.network(5) - daemon config files, see
systemd-system.conf(5),systemd-user.conf(5),logind.conf(5),journald.conf(5),journal-remote.conf(5),journal-upload.conf(5),systemd-sleep.conf(5),timesyncd.conf(5) - nspawn files, see
systemd.nspawn(5)
ngl the syntax is inspired by the XDG Desktop Entry Specification[1] .desktop files โ which are themselves inspired by Microsoft Windows .ini files. it's giving family tree, it's giving inherited the drip. ๐
๐ the actual rules, bestie
Every file is a plain text file divided into sections, with config entries in the style key=value. Whitespace immediately before or after the = is ignored โ she does not care, she is unbothered. โจ
Empty lines and lines starting with # or ; are ignored, and those are what you use for commenting. (yes, both. pick your fighter. ๐
)
Lines ending in a backslash get concatenated with the following line while reading, and the backslash is replaced by a space character. This is the move when you wanna wrap a long line. The limit on line length is very large (currently 1 MB) โ but lowkey, please avoid such long lines and instead use multiple directives, variable substitution, or whatever other mechanism makes sense for that file type. ๐ซถ
And here's the spicy part: when a comment line (or lines) follows a line ending with a backslash, the comment block is ignored, so the continued line is concatenated with whatever follows the comment block. not the comment itself, the thing after the comment block. iykyk.
[Section A]
KeyOne=value 1
KeyTwo=value 2
# a comment
[Section B]
Setting="something" "some thing" "..."
KeyTwo=value 2 \
value 2 continued
[Section C]
KeyThree=value 3\
# this line is ignored
; this line is ignored too
value 3 continued
โ boolean arguments
Boolean arguments in config files can be written in various formats, bestie:
- for positive settings, the strings
1,yes,trueandonare all equivalent - for negative settings, the strings
0,no,falseandoffare all equivalent
pick whichever one matches your aesthetic, they all slay the same. ๐
โฑ๏ธ time span values
Time span values can also be written in various formats:
- a stand-alone number specifies a time in seconds
- if suffixed with a time unit, the unit is honored
- a concatenation of multiple values with units is supported โ in which case the values are added up โจ
Example time, fr fr: "50" refers to 50 seconds. "2min 200ms" refers to 2 minutes and 200 milliseconds, i.e. 120200 ms.
The following time units are understood: "s", "min", "h", "d", "w", "ms", "us".
For details see systemd.time(7).
๐ specifying the same setting more than once
Various settings are allowed to be specified more than once, and in that case the interpretation depends on the setting. Often, multiple settings form a list, and setting to an empty value "resets", which means that previous assignments are ignored. When this is allowed, it's mentioned in the description of the setting โ so read the setting's own page, bestie, don't just assume. ๐
โ ๏ธ Note that using multiple assignments to the same value makes the file incompatible with parsers for the XDG .desktop file format. so like, pick a lane. ๐
๐ QUOTING ๐
For settings where quoting is allowed, here's the general tea. โ
Double quotes ("...") and single quotes ('...') may be used to wrap a whole item. The rules are very specific and she will notice if you break them:
- the opening quote may appear only at the beginning or after whitespace that is not quoted
- the closing quote must be followed by whitespace or the end of line
In which case, everything until the next matching quote becomes part of the same item, and the quotes themselves are removed. iconic behaviour, honestly. โจ
C-style escapes are supported. The list of known escape patterns is below ๐
๐จ Only escape patterns which match the syntax in the list are allowed. Other patterns may be added in the future, and unknown patterns will result in a warning. In particular, any backslashes should be doubled. ๐
Finally, a trailing backslash (\) may be used to merge lines, as described above.
UTF-8 is accepted, and hence typical unicode characters do not need to be escaped. she speaks your language, literally. ๐๐
๐ฆ supported escapes
"\a"โ bell"\b"โ backspace"\f"โ form feed"\n"โ newline"\r"โ carriage return"\t"โ tab"\v"โ vertical tab"\\"โ backslash"\""โ double quotation mark"\'"โ single quotation mark"\s"โ space"\xxx"โ character number xx in hexadecimal encoding"\nnn"โ character number nnn in octal encoding"\unnnn"โ unicode code point nnnn in hexadecimal encoding"\Unnnnnnnn"โ unicode code point nnnnnnnn in hexadecimal encoding
๐ SEE ALSO ๐
๐ NOTES ๐
- XDG Desktop Entry Specification
https://standards.freedesktop.org/desktop-entry-spec/latest/
and that's the whole page, bestie โ you ate that. ๐ โจ
this was systemd 262.1, and yes the manual page really is called SYSTEMD.SYNTAX(7). go forth and configure responsibly. ๐๐ฆ๐
๐ฆ where this page comes from
- arch rolling: systemd 262.1-1 ยท LGPL-2.1-or-later AND CC0-1.0 AND GPL-2.0-or-later AND MIT-0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms