LinuxCommandLibrary

systemctl-list-paths

List systemd path units

TLDR

Show all path units currently in memory

$ systemctl list-paths
copy

List path units matching specific wildcard pattern ie, shell-globbing
$ systemctl list-paths [pattern]
copy

List path units that match with multiple patterns
$ systemctl list-paths [pattern_1 pattern_2 ...]
copy

Show all path units, including inactive ones
$ systemctl list-paths --all
copy

Filter path units by state
$ systemctl list-paths --state [state]
copy

Also show unit types in the output
$ systemctl list-paths --show-types
copy

SYNOPSIS

systemctl list-paths [PATTERN...] [OPTIONS...]

PARAMETERS

PATTERN...
    One or more patterns to filter the displayed path units. Only units whose names match one of the specified patterns will be shown. Patterns can include shell-style wildcards.

--all, -a
    Show all loaded units, regardless of their current state. By default, `list-paths` might only show active units.

--full, -l
    Do not truncate unit names or descriptions in the output, showing full information.

--no-pager
    Do not pipe the output into a pager. This is useful when scripting or redirecting output.

--no-legend
    Do not print the header line that describes the columns.

--output=FORMAT
    Specify the output format. Common formats include brief (default), json, json-pretty, short, plain, etc.

DESCRIPTION

The `systemctl list-paths` command provides a comprehensive overview of all currently loaded and active path units managed by systemd. Path units are a special type of systemd unit designed to monitor specific file paths or directories for changes. When a monitored path changes, the associated path unit can trigger other systemd units, typically service units, to perform actions. This mechanism is useful for reacting to file system events, such as a new file appearing in a spool directory or a configuration file being modified. The output typically displays information such as the unit's name, whether it's loaded, its active state, and a brief description. Users can filter the output by providing patterns as arguments, allowing them to focus on specific path units or groups of units. This command is an essential tool for administrators to inspect the state of file system event-driven automation and diagnose issues related to path-triggered services. It helps in understanding which parts of the system are configured to react to file system changes and their current operational status.

CAVEATS

The command only lists loaded path units. If a path unit file exists but has not been enabled or started, it will not appear in the output until systemd loads it.
The `ACTIVE` state for path units indicates whether the unit is currently watching the specified path, not whether its associated service has been triggered.
For detailed information about a specific path unit, use `systemctl status .path`.

PATH UNIT DEFINITION

Path units are defined in files ending with .path (e.g., /etc/systemd/system/mywatcher.path). They typically contain an [Path] section specifying the paths to monitor (e.g., PathExists=, PathChanged=) and an [Install] section. When a path unit is activated, it usually triggers a corresponding service unit (e.g., mywatcher.service) with the same base name.

COMMON USE CASES

Path units are commonly used for tasks such as:
- Automatically processing files dropped into a specific directory (e.g., print spoolers, mail queues).
- Restarting services when a configuration file they depend on changes.
- Triggering backups or synchronization tasks upon file modifications.

HISTORY

The `list-paths` command is an integral part of systemd, which replaced the traditional SysVinit system as the default init system in many Linux distributions starting around 2011-2012. Systemd introduced the concept of path units as a robust and efficient way to handle file system events, offering a more integrated and reliable alternative to polling or `inotify` scripts for triggering services. The `list-paths` subcommand was developed as a necessary diagnostic tool to monitor and manage these new unit types, reflecting systemd's broader philosophy of providing comprehensive control and introspection over system components. Its functionality has remained consistent, evolving with other systemctl features for better output and filtering options.

SEE ALSO

systemctl(1), systemctl list-units(1), systemctl list-timers(1), systemctl status(1), systemd.path(5), systemd.unit(5)

Copied to clipboard