chiark / gitweb /
systemctl: allow globbing in commands which take multiple unit names
[elogind.git] / man / systemctl.xml
index 33a293581ce0ee7d96b9b11fea34a08d32f41faa..13a4444a0437e16aecd274d2282a65c1cd59ea0e 100644 (file)
@@ -63,19 +63,6 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
     introspect and control the state of the
     <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
     system and service manager.</para>
-
-    <para>For unit commands, the <replaceable>NAME</replaceable> represents full name of the unit.
-    <programlisting>
-systemctl start foo.service
-    </programlisting>
-    For unit file commands, the <replaceable>NAME</replaceable> represents the full name of the unit file, or the absolute path to the unit file.
-    <programlisting>
-systemctl start /path/to/foo.service
-    </programlisting>
-    While working with services/service files, <command>systemctl</command> implicitly appends the ".service" suffix when it is missing.
-    <programlisting>
-systemctl start foo
-    </programlisting></para>
   </refsect1>
 
   <refsect1>
@@ -187,22 +174,11 @@ systemctl start foo
         <term><option>--full</option></term>
 
         <listitem>
-          <para>Do not ellipsize unit names, process tree entries, and
-          truncate unit descriptions in the output of
-          <command>list-units</command> and
-          <command>list-jobs</command>.</para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term><option>--fail</option></term>
-
-        <listitem>
-          <para>If the requested operation conflicts with a pending
-          unfinished job, fail the command. If this is not specified,
-          the requested operation will replace the pending job, if
-          necessary. Do not confuse with
-          <option>--failed</option>.</para>
+          <para>Do not ellipsize unit names, process tree entries,
+          journal output, or truncate unit descriptions in the output
+          of <command>status</command>, <command>list-units</command>,
+          <command>list-jobs</command>, and
+          <command>list-timers</command>.</para>
         </listitem>
       </varlistentry>
 
@@ -215,27 +191,58 @@ systemctl start foo
       </varlistentry>
 
       <varlistentry>
-        <term><option>--irreversible</option></term>
+        <term><option>--job-mode=</option></term>
 
         <listitem>
-          <para>Mark this transaction's jobs as irreversible. This prevents
-          future conflicting transactions from replacing these jobs.
-          The jobs can still be cancelled using the <command>cancel</command>
-          command.</para>
+        <para>When queuing a new job, this option controls how to deal with
+        already queued jobs. It takes one of <literal>fail</literal>,
+        <literal>replace</literal>,
+        <literal>replace-irreversibly</literal>,
+        <literal>isolate</literal>,
+        <literal>ignore-dependencies</literal>,
+        <literal>ignore-requirements</literal> or
+        <literal>flush</literal>. Defaults to
+        <literal>replace</literal>, except when the
+        <command>isolate</command> command is used which implies the
+        <literal>isolate</literal> job mode.</para>
+
+        <para>If <literal>fail</literal> is specified and a requested
+        operation conflicts with a pending job (more specifically:
+        causes an already pending start job to be reversed into a stop
+        job or vice versa), cause the operation to fail.</para>
+
+        <para>If <literal>replace</literal> (the default) is
+        specified, any conflicting pending job will be replaced, as
+        necessary.</para>
+
+        <para>If <literal>replace-irreversibly</literal> is specified,
+        operate like <literal>replace</literal>, but also mark the new
+        jobs as irreversible. This prevents future conflicting
+        transactions from replacing these jobs. The jobs can still be
+        cancelled using the <command>cancel</command> command.</para>
+
+        <para><literal>isolate</literal> is only valid for start
+        operations and causes all other units to be stopped when the
+        specified unit is started. This mode is always used when the
+        <command>isolate</command> command is used.</para>
+
+        <para><literal>flush</literal> will cause all queued jobs to
+        be canceled when the new job is enqueued.</para>
+
+        <para>If <literal>ignore-dependencies</literal> is specified,
+        then all unit dependencies are ignored for this new job and
+        the operation is executed immediately. If passed, no required
+        units of the unit passed will be pulled in, and no ordering
+        dependencies will be honored. This is mostly a debugging and
+        rescue tool for the administrator and should not be used by
+        applications.</para>
+
+        <para><literal>ignore-requirements</literal> is similar to
+        <literal>ignore-dependencies</literal>, but only causes the
+        requirement dependencies to be ignored, the ordering
+        dependencies will still be honoured.</para>
         </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term><option>--ignore-dependencies</option></term>
 
-        <listitem>
-          <para>When enqueuing a new job, ignore all its dependencies
-          and execute it immediately. If passed, no required units of
-          the unit passed will be pulled in, and no ordering
-          dependencies will be honored. This is mostly a debugging and
-          rescue tool for the administrator and should not be used by
-          applications.</para>
-        </listitem>
       </varlistentry>
 
       <varlistentry>
@@ -250,7 +257,7 @@ systemctl start foo
           sleep state. Any user may take these locks and privileged
           users may override these locks. If any locks are taken,
           shutdown and sleep state requests will normally fail
-          (regardless if privileged or not) and a list of active locks
+          (regardless of whether privileged or not) and a list of active locks
           is printed. However, if <option>--ignore-inhibitors</option>
           is specified, the locks are ignored and not printed, and the
           operation attempted anyway, possibly requiring additional
@@ -288,7 +295,7 @@ systemctl start foo
         <term><option>--no-legend</option></term>
 
         <listitem>
-          <para>Do not print a legend, i.e.  the column headers and
+          <para>Do not print the legend, i.e. the column headers and
           the footer with hints.</para>
         </listitem>
       </varlistentry>
@@ -437,7 +444,7 @@ systemctl start foo
 
         <listitem>
           <para>When used with <command>enable</command>,
-          <command>disable</command>, <command>is-enabled</command>
+          <command>disable</command>,
           (and related commands), make changes only temporarily, so
           that they are lost on the next reboot. This will have the
           effect that changes are not made in subdirectories of
@@ -445,7 +452,7 @@ systemctl start foo
           with identical immediate effects, however, since the latter
           is lost on reboot, the changes are lost too.</para>
 
-          <para>Similar, when used with
+          <para>Similarly, when used with
           <command>set-property</command>, make changes only
           temporarily, so that they are lost on the next
           reboot.</para>
@@ -520,22 +527,26 @@ systemctl start foo
 
       <variablelist>
         <varlistentry>
-          <term><command>list-units</command></term>
+          <term><command>list-units <optional><replaceable>PATTERN</replaceable>...</optional></command></term>
 
           <listitem>
             <para>List known units (subject to limitations specified
-            with <option>-t</option>).</para>
+            with <option>-t</option>). If one or more
+            <replaceable>PATTERN</replaceable>s are specified, only
+            units matching one of them are shown.</para>
 
             <para>This is the default command.</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term><command>list-sockets</command></term>
+          <term><command>list-sockets <optional><replaceable>PATTERN</replaceable>...</optional></command></term>
 
           <listitem>
-            <para>List socket units ordered by the listening address. Produces output
-            similar to
+            <para>List socket units ordered by listening address.
+            If one or more <replaceable>PATTERN</replaceable>s are
+            specified, only socket units matching one of them are
+            shown. Produces output similar to
             <programlisting>
 LISTEN           UNIT                        ACTIVATES
 /dev/initctl     systemd-initctl.socket      systemd-initctl.service
@@ -555,10 +566,13 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
         </varlistentry>
 
         <varlistentry>
-          <term><command>list-timers</command></term>
+          <term><command>list-timers <optional><replaceable>PATTERN</replaceable>...</optional></command></term>
 
           <listitem>
-            <para>List timer units ordered by the time they elapse next.</para>
+            <para>List timer units ordered by the time they elapse
+            next. If one or more <replaceable>PATTERN</replaceable>s
+            are specified, only units matching one of them are shown.
+            </para>
 
             <para>See also the options <option>--all</option> and
             <option>--failed</option>.</para>
@@ -566,15 +580,24 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
         </varlistentry>
 
         <varlistentry>
-          <term><command>start <replaceable>NAME</replaceable>...</command></term>
+          <term><command>start <replaceable>PATTERN</replaceable>...</command></term>
 
           <listitem>
             <para>Start (activate) one or more units specified on the
             command line.</para>
+
+            <para>Note that glob patterns operate on a list of currently
+            loaded units. Units which are not active and are not in a
+            failed state usually are not loaded, and would not be
+            matched by any pattern. In addition, in case of
+            instantiated units, systemd is often unaware of the
+            instance name until the instance has been started. Therefore
+            using glob patterns with <command>start</command>
+            has limited usefulness.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><command>stop <replaceable>NAME</replaceable>...</command></term>
+          <term><command>stop <replaceable>PATTERN</replaceable>...</command></term>
 
           <listitem>
             <para>Stop (deactivate) one or more units specified on the
@@ -582,7 +605,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><command>reload <replaceable>NAME</replaceable>...</command></term>
+          <term><command>reload <replaceable>PATTERN</replaceable>...</command></term>
 
           <listitem>
             <para>Asks all units listed on the command line to reload
@@ -603,7 +626,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
 
         </varlistentry>
         <varlistentry>
-          <term><command>restart <replaceable>NAME</replaceable>...</command></term>
+          <term><command>restart <replaceable>PATTERN</replaceable>...</command></term>
 
           <listitem>
             <para>Restart one or more units specified on the command
@@ -612,7 +635,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><command>try-restart <replaceable>NAME</replaceable>...</command></term>
+          <term><command>try-restart <replaceable>PATTERN</replaceable>...</command></term>
 
           <listitem>
             <para>Restart one or more units specified on the command
@@ -623,7 +646,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><command>reload-or-restart <replaceable>NAME</replaceable>...</command></term>
+          <term><command>reload-or-restart <replaceable>PATTERN</replaceable>...</command></term>
 
           <listitem>
             <para>Reload one or more units if they support it. If not,
@@ -632,7 +655,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><command>reload-or-try-restart <replaceable>NAME</replaceable>...</command></term>
+          <term><command>reload-or-try-restart <replaceable>PATTERN</replaceable>...</command></term>
 
           <listitem>
             <para>Reload one or more units if they support it. If not,
@@ -662,7 +685,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><command>kill <replaceable>NAME</replaceable>...</command></term>
+          <term><command>kill <replaceable>PATTERN</replaceable>...</command></term>
 
           <listitem>
             <para>Send a signal to one or more processes of the
@@ -673,18 +696,18 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><command>is-active <replaceable>NAME</replaceable>...</command></term>
+          <term><command>is-active <replaceable>PATTERN</replaceable>...</command></term>
 
           <listitem>
             <para>Check whether any of the specified units are active
             (i.e. running). Returns an exit code 0 if at least one is
-            active, non-zero otherwise. Unless <option>--quiet</option>
+            active, or non-zero otherwise. Unless <option>--quiet</option>
             is specified, this will also print the current unit state to
             STDOUT.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><command>is-failed <replaceable>NAME</replaceable>...</command></term>
+          <term><command>is-failed <replaceable>PATTERN</replaceable>...</command></term>
 
           <listitem>
             <para>Check whether any of the specified units are in a "failed" state.
@@ -695,7 +718,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><command>status [<replaceable>NAME</replaceable>...|<replaceable>PID</replaceable>...]</command></term>
+          <term><command>status</command> <optional><replaceable>PATTERN</replaceable>...|<replaceable>PID</replaceable>...]</optional></term>
 
           <listitem>
             <para>Show terse runtime status information about one or
@@ -706,12 +729,22 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
             belongs to.</para>
 
             <para>This function is intended to generate human-readable
-            output. If you are looking for computer-parsable output, use
-            <command>show</command> instead.</para>
+            output. If you are looking for computer-parsable output,
+            use <command>show</command> instead. By default this
+            function only shows 10 lines of output and ellipsizes
+            lines to fit in the terminal window. This can be changes
+            with <option>--lines</option> and <option>--full</option>,
+            see above. In addition, <command>journalctl
+            --unit=<replaceable>NAME</replaceable></command> or
+            <command>journalctl
+            --user-unit=<replaceable>NAME</replaceable></command> use
+            a similar filter for messages and might be more
+            convenient.
+            </para>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><command>show [<replaceable>NAME</replaceable>...|<replaceable>JOB</replaceable>...]</command></term>
+          <term><command>show</command> <optional><replaceable>PATTERN</replaceable>...|<replaceable>JOB</replaceable>...</optional></term>
 
           <listitem>
             <para>Show properties of one or more units, jobs, or the
@@ -727,7 +760,16 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
             human-readable output.</para>
           </listitem>
         </varlistentry>
+        <varlistentry>
+          <term><command>cat <replaceable>PATTERN</replaceable>...</command></term>
 
+          <listitem>
+            <para>Show backing files of one or more units. Prints the
+            "fragment" and "drop-ins" (source files) of units. Each
+            file is preceded by a comment which includes the file
+            name.</para>
+          </listitem>
+        </varlistentry>
         <varlistentry>
           <term><command>set-property <replaceable>NAME</replaceable> <replaceable>ASSIGNMENT</replaceable>...</command></term>
 
@@ -755,7 +797,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
         </varlistentry>
 
         <varlistentry>
-          <term><command>help <replaceable>NAME</replaceable>...|<replaceable>PID</replaceable>...</command></term>
+          <term><command>help <replaceable>PATTERN</replaceable>...|<replaceable>PID</replaceable>...</command></term>
 
           <listitem>
             <para>Show manual pages for one or more units, if
@@ -765,7 +807,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
         </varlistentry>
 
         <varlistentry>
-          <term><command>reset-failed [<replaceable>NAME</replaceable>...]</command></term>
+          <term><command>reset-failed [<replaceable>PATTERN</replaceable>...]</command></term>
 
           <listitem>
             <para>Reset the <literal>failed</literal> state of the
@@ -799,10 +841,13 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
 
       <variablelist>
         <varlistentry>
-          <term><command>list-unit-files</command></term>
+          <term><command>list-unit-files <optional><replaceable>PATTERN...</replaceable></optional></command></term>
 
           <listitem>
-            <para>List installed unit files.</para>
+            <para>List installed unit files. If one or more
+            <replaceable>PATTERN</replaceable>s are specified, only
+            units whose filename (just the last component of the path)
+            matches one of them are shown.</para>
           </listitem>
         </varlistentry>
 
@@ -895,10 +940,64 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
 
           <listitem>
             <para>Checks whether any of the specified unit files are
-            enabled (as with <command>enable</command>). Returns an exit
-            code of 0 if at least one is enabled, non-zero
-            otherwise. Prints the current enable status. To suppress
-            this output, use <option>--quiet</option>.</para>
+            enabled (as with <command>enable</command>). Returns an
+            exit code of 0 if at least one is enabled, non-zero
+            otherwise. Prints the current enable status (see table).
+            To suppress this output, use <option>--quiet</option>.
+            </para>
+
+            <table>
+              <title>
+                <command>is-enabled</command> output
+              </title>
+
+              <tgroup cols='3'>
+                <thead>
+                  <row>
+                    <entry>Printed string</entry>
+                    <entry>Meaning</entry>
+                    <entry>Return value</entry>
+                  </row>
+                </thead>
+                <tbody>
+                  <row>
+                    <entry><literal>enabled</literal></entry>
+                    <entry morerows='1'>Enabled through a symlink in <filename>.wants</filename> directory (permanently or just in <filename>/run</filename>)</entry>
+                    <entry morerows='1'>0</entry>
+                  </row>
+                  <row>
+                    <entry><literal>enabled-runtime</literal></entry>
+                  </row>
+                  <row>
+                    <entry><literal>linked</literal></entry>
+                    <entry morerows='1'>Made available through a symlink to the unit file (permanently or just in <filename>/run</filename>)</entry>
+                    <entry morerows='1'>1</entry>
+                  </row>
+                  <row>
+                    <entry><literal>linked-runtime</literal></entry>
+                  </row>
+                  <row>
+                    <entry><literal>masked</literal></entry>
+                    <entry morerows='1'>Disabled entirely (permanently or just in <filename>/run</filename>)</entry>
+                    <entry morerows='1'>1</entry>
+                  </row>
+                  <row>
+                    <entry><literal>masked-runtime</literal></entry>
+                  </row>
+                  <row>
+                    <entry><literal>static</literal></entry>
+                    <entry>Unit is not enabled, but has no provisions for enabling in [Install] section</entry>
+                    <entry>0</entry>
+                  </row>
+                  <row>
+                    <entry><literal>disabled</literal></entry>
+                    <entry>Unit is not enabled</entry>
+                    <entry>1</entry>
+                  </row>
+                </tbody>
+              </tgroup>
+            </table>
+
           </listitem>
         </varlistentry>
 
@@ -998,10 +1097,12 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
 
       <variablelist>
         <varlistentry>
-          <term><command>list-jobs</command></term>
+          <term><command>list-jobs <optional><replaceable>PATTERN...</replaceable></optional></command></term>
 
           <listitem>
-            <para>List jobs that are in progress.</para>
+            <para>List jobs that are in progress. If one or more
+            <replaceable>PATTERN</replaceable>s are specified, only
+            jobs for units matching one of them are shown.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
@@ -1021,7 +1122,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
 
       <variablelist>
         <varlistentry>
-          <term><command>snapshot [<replaceable>NAME</replaceable>]</command></term>
+          <term><command>snapshot <optional><replaceable>NAME</replaceable></optional></command></term>
 
           <listitem>
             <para>Create a snapshot. If a snapshot name is specified,
@@ -1045,7 +1146,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><command>delete <replaceable>NAME</replaceable>...</command></term>
+          <term><command>delete <replaceable>PATTERN</replaceable>...</command></term>
 
           <listitem>
             <para>Remove a snapshot previously created with
@@ -1266,7 +1367,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><command>switch-root <replaceable>ROOT</replaceable> [<replaceable>INIT</replaceable>]</command></term>
+          <term><command>switch-root <replaceable>ROOT</replaceable> <optional><replaceable>INIT</replaceable></optional></command></term>
 
           <listitem>
             <para>Switches to a different root directory and executes a
@@ -1288,6 +1389,60 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
       </variablelist>
     </refsect2>
 
+    <refsect2>
+      <title>Parameter Syntax</title>
+
+      <para>Unit ommands listed above take either a single unit name
+      (designated as <replaceable>NAME</replaceable>), or multiple
+      unit specifications (designated as
+      <replaceable>PATTERN</replaceable>...). In the first case, the
+      unit name with or without a suffix must be given. If the suffix
+      is not specified, systemctl will append a suitable suffix,
+      <literal>.service</literal> by default, and a type-specific
+      suffix in case of commands which operate only on specific unit
+      types. For example,
+      <programlisting># systemctl start sshd</programlisting> and
+      <programlisting># systemctl start sshd.service</programlisting>
+      are equivalent, as are
+      <programlisting># systemctl isolate snapshot-11</programlisting>
+      and
+      <programlisting># systemctl isolate snapshot-11.snapshot</programlisting>
+      Note that (absolute) paths to device nodes are automatically
+      converted to device unit names, and other (absolute) paths to
+      mount unit names.
+      <programlisting># systemctl status /dev/sda
+# systemctl status /home</programlisting>
+      are equivalent to:
+      <programlisting># systemctl status dev-sda.device
+# systemctl status home.mount</programlisting>
+      In the second case, shell-style globs will be matched against
+      currently loaded units, and 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.</para>
+
+      <para>Glob patterns use
+      <citerefentry><refentrytitle>fnmatch</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+      so normal shell-style globbing rules are used, and
+      <literal>*</literal>, <literal>?</literal>,
+      <literal>[]</literal> may be used. See
+      <citerefentry><refentrytitle>glob</refentrytitle><manvolnum>7</manvolnum></citerefentry>
+      for more details. The patterns are matched against the names of
+      currently loaded units, and patterns which don't match anything
+      are silently skipped. For example:
+      <programlisting># systemctl stop sshd@*.service</programlisting>
+      will stop all <filename>sshd@.service</filename> instances.
+      </para>
+
+      <para>For unit file commands, the specified
+      <replaceable>NAME</replaceable> should be the full name of the
+      unit file, or the absolute path to the unit file:
+      <programlisting># systemctl enable foo.service</programlisting>
+      or
+      <programlisting># systemctl link /path/to/foo.service</programlisting>
+      </para>
+    </refsect2>
+
   </refsect1>
 
   <refsect1>
@@ -1327,6 +1482,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
       <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
       <citerefentry><refentrytitle>wall</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
       <citerefentry><refentrytitle>systemd.preset</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+      <citerefentry><refentrytitle>glob</refentrytitle><manvolnum>7</manvolnum></citerefentry>
     </para>
   </refsect1>