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:

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, true and on are all equivalent
  • for negative settings, the strings 0, no, false and off are 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 ๐ŸŒˆ

systemd(1), systemd.time(7)


๐Ÿ“Ž NOTES ๐Ÿ“Ž

  1. 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