commands

systemctl — Inspect and manage systemd units

status and is-active query live state. enable and disable modify installation links; --root selects an offline filesystem for supported unit-file operations. start and stop act on the manager. daemon-reload rereads definitions; reload asks a supporting service to reload. Administrative changes require authorization. Use a fresh private workspace; live operations are VM-only.

Formal Syntax & Structure

linux syntaxlinux
systemctl [OPTIONS] COMMAND [UNIT...]

Parameters & Attributes

NameTypeDescription
COMMANDoperandOperation such as status or is-enabled
UNIToperandTarget unit where required
--rootoptionAlternate filesystem root for offline unit-file operations

Return Value

exit status and output

status and is-active query live state. enable and disable modify installation links; --root selects an offline filesystem for supported unit-file operations. start and stop act on the manager. daemon-reload rereads definitions; reload asks a supporting service to reload. Administrative changes require authorization.

Working Example

Example Snippetlinux
rc=0state=$(systemctl --root="$PWD/offline" is-enabled bm-report.service) || rc=$?printf "%s\n" "$state"if [[ $state == disabled && $rc -eq 1 ]]; then  printf "not enabled\n"else  exit 1fi
Linux Reference