Find the Paths systemd and Your User Session Actually Use
You will finish with a reliable way to inspect the directories known to systemd, query one path for a script, and distinguish a single directory from a colon-separated search path. The examples use systemd 255.4-1ubuntu8.17 from the installed systemd package.
The route
Jump straight to the step you need, or tick off Done means at the end.
Allow about ten minutes. You need a shell and the systemd-path command. Everything here is read-only: no root access, service restart or configuration edit is required.
1. Check the installed command
Start by confirming which executable is being used and which package supplied it:
$ command -v systemd-path
/usr/bin/systemd-path
$ dpkg-query -W -f='\${Package} \${Version}\n' systemd
systemd 255.4-1ubuntu8.17
The exact package revision will differ on another host. The command reports the systemd version with --version, which is useful when comparing output from different machines.
$ systemd-path --version
systemd 255 (255.4-1ubuntu8.17)
Checkpoint
If command -v finds nothing, stop here and install or repair the package through your normal distribution process. Do not copy a path from another host into a script.
2. List the current system and user paths
With no path name, the command prints the known names and their current values. Use --no-pager so a script, terminal recording or remote session receives the complete output directly:
$ systemd-path --no-pager
temporary: /tmp
system-binaries: /usr/bin
system-configuration: /etc
system-runtime: /run
system-state-logs: /var/log
user-binaries: /home/andy/.local/bin
user-configuration: /home/andy/.config
user-runtime: /run/user/1004
user: /home/andy
search-binaries: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
systemd-system-unit: /usr/lib/systemd/system
systemd-user-unit: /usr/lib/systemd/user
This is representative output, not a portable list. Values depend on the user, architecture, runtime state and distribution layout. For example, user-runtime is tied to the active user session, while system-binaries describes a system location.
Checkpoint
Treat the names on the left as the interface and the paths on the right as host-specific data. If you need a value in a script, query that name instead of parsing this whole listing.
3. Query one directory for a script
Pass one known name after the options. This is the useful form for a deployment check or diagnostic command:
$ systemd-path --no-pager system-configuration
/etc
$ systemd-path --no-pager systemd-system-unit
/usr/lib/systemd/system
When a name is supplied, the output is the value only, without the name: label used by the full listing. Capture it as data, not as a command to execute:
config_dir=$(systemd-path --no-pager system-configuration) || exit $?
printf 'system configuration: %s\n' "$config_dir"
The command returns zero on success and a non-zero status on failure. Keep the status check: a missing or mistyped name must not silently turn into an empty directory variable.
4. Understand search paths
Names beginning with search- are different. They represent an ordered, colon-separated list rather than one directory. For example:
$ systemd-path --no-pager search-binaries-default
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
$ systemd-path --no-pager search-configuration
/home/andy/.config:/etc
Read the result with a path-list tool or shell loop when order matters. Do not join entries with spaces, and do not assume the first directory is writable. A search path is a lookup order, not a permission grant.
search_path=$(systemd-path --no-pager search-binaries-default) || exit $?
old_ifs=$IFS
IFS=:
for directory in $search_path; do
printf 'candidate: %s\n' "$directory"
done
IFS=$old_ifs
That simple loop is suitable for the ordinary absolute directories shown here. If you are handling untrusted input or paths that may contain unusual shell characters, use a language with an explicit path-list parser instead of expanding a variable in the shell.
5. Add a suffix without changing anything
--suffix= appends text to printed paths. It is useful for inspecting a predictable child path, but it does not create the result and does not check that the result exists:
$ systemd-path --no-pager --suffix=/example system-binaries user-binaries
/usr/bin/example
/home/andy/.local/bin/example
Use this as formatting, not validation. If the next operation needs a real directory or file, test it separately with test, stat or the operation that will consume it. Do not use a suffix to build a path from untrusted text without checking the resulting path's purpose and boundaries.
6. Diagnose a name or version mismatch
A tempting mistake is to invent a name from a phrase in a script. The installed command recognises documented names such as system-binaries and search-binaries-default; similar-looking names are not automatically aliases:
$ systemd-path --no-pager search-paths-default
Path 'search-paths-default' not known.
The error text and exact exit status can vary with the systemd build, so check the status directly when scripting:
if value=$(systemd-path --no-pager system-binaries); then
printf 'system binaries: %s\n' "$value"
else
status=$?
printf 'systemd-path query failed with status %s\n' "$status" >&2
exit "$status"
fi
If two hosts disagree, compare systemd-path --version, the logged-in user, the architecture and the relevant environment. The tool exposes the current machine's paths; it is not a compatibility database for another distribution.
Done means
- You confirmed the installed
systemd-pathbinary and systemd version. - You can list paths without a pager and query one named path directly.
- You know that
search-values are ordered, colon-separated lists. - You use
--suffix=only to print a derived path, then validate it separately when needed. - Your scripts check the command's exit status instead of accepting an empty or mistyped result.