The [PATTERN] parameter for “systemctl list-units”

systemd

The man page for systemctl says:

Unit Commands

list-units [PATTERN…] List known units (subject to limitations
specified with -t). If one or more PATTERNs are specified, only units
matching one of them are shown.

This is the default command.

My question is what does it mean by [PATTERN].

When I execute systemctl list-units I get relatively long list of the loaded units. But if I add a third argument I get an error message Too many arguments. So I am curious as to what parameters are valid for the [PATTERN] argument listed in the man page.

(I'm running Arch Linux and have version 227 of systemd)

Best Answer

From the same page:

Parameter Syntax

Unit commands listed above take either a single unit name (designated as NAME), or multiple unit specifications (designated as PATTERN...). In the first case, [...]

In the second case, shell-style globs will be matched against currently loaded units; literal unit names, with or without a suffix, will be treated as in the first case. This means that literal unit names always refer to exactly one unit, but globs may match zero units and this is not considered an error.

Glob patterns use fnmatch(3), so normal shell-style globbing rules are used, and "*", "?", "[]" may be used. See glob(7) for more details. The patterns are matched against the names of currently loaded units, and patterns which do not match anything are silently skipped. For example:

# systemctl stop sshd@*.service

will stop all sshd@.service instances.