LinuxCommandLibrary

systemd-escape

Escape strings for systemd unit names

TLDR

Escape the given text

$ systemd-escape [text]
copy
Reverse the escaping process
$ systemd-escape -u [text]
copy
Treat the given text as a path
$ systemd-escape -p [text]
copy
Append a suffix to the escaped text
$ systemd-escape --suffix [suffix] [text]
copy
Use a template and inject the escaped text
$ systemd-escape --template [template] [text]
copy

SYNOPSIS

systemd-escape [options] [string...]

DESCRIPTION

systemd-escape converts arbitrary strings into valid systemd unit name components. Systemd unit names have strict naming rules, and this tool handles the encoding of special characters.
This is particularly useful when creating mount units or template instances where paths or other strings must be encoded. The escaping follows systemd's unit name escaping rules.

PARAMETERS

-u, --unescape

Reverse the escaping (decode)
-p, --path
Escape a file system path
--suffix _suffix_
Append unit type suffix (.service, .mount, etc.)
--template _template_
Insert escaped string into template at @ position
-m, --mangle
Mangle string to be suitable as unit name
--instance
Print only the instance part of a template

CAVEATS

Forward slashes in paths become dashes when escaped. The --path option handles leading slashes specially. Empty strings and certain special cases have defined escape sequences. Part of the systemd suite.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community