wiki/cli.systemctl.html
2022-07-29 15:41:17 +00:00

33 lines
13 KiB
HTML

<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width"/><meta charSet="utf-8"/><title>Command line: systemctl</title><script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script><script id="MathJax-script" async="" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script><script type="text/x-mathjax-config">
MathJax = {
tex: {
inlineMath: [ [&#x27;$&#x27;,&#x27;$&#x27;], [&#x27;\(&#x27;,&#x27;\)&#x27;] ],
displayMath: [ [&#x27;$$&#x27;,&#x27;$$&#x27;], [&#x27;[&#x27;,&#x27;]&#x27;] ]
},
options = {
processHtmlClass = &quot;math&quot;
}
}
</script><meta name="next-head-count" content="6"/><link rel="preload" href="/wiki/_next/static/css/52fc2ba29703df73922c.css" as="style"/><link rel="stylesheet" href="/wiki/_next/static/css/52fc2ba29703df73922c.css" data-n-g=""/><noscript data-n-css=""></noscript><link rel="preload" href="/wiki/_next/static/chunks/main-ae4733327bd95c4ac325.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/webpack-50bee04d1dc61f8adf5b.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/framework.9d524150d48315f49e80.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/commons.0e1c3f9aa780c2dfe9f0.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/pages/_app-8e3d0c58a60ec788aa69.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/940643274e605e7596ecea1f2ff8d83317a3fb76.4841a16762f602a59f00.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/pages/%5B%5B...slug%5D%5D-1aa198f87ede1cd0e1dc.js" as="script"/></head><body><div id="__next"><main><h1>Command line: systemctl</h1><section class="post-metadata"><span>Date: <!-- -->2021-07-27 13:47:34 +08:00</span><span>Date modified: <!-- -->2021-07-27 14:06:35 +08:00</span></section><nav class="toc"><ol class="toc-level toc-level-1"><li class="toc-item toc-item-h1"><a href="/wiki/cli.systemctl#synopsis" class="toc-link toc-link-h1">Synopsis</a></li><li class="toc-item toc-item-h1"><a href="/wiki/cli.systemctl#options" class="toc-link toc-link-h1">Options</a></li><li class="toc-item toc-item-h1"><a href="/wiki/cli.systemctl#subcommands" class="toc-link toc-link-h1">Subcommands</a></li></ol></nav><p>The go-to command to manage units in a systemd-ful system.
</p><p>For full details, you can view the <code class="inline-verbatim">systemctl.1</code> manual page.
</p><h1 id="synopsis">Synopsis</h1><pre class="src-block"><code class="language-shell">systemctl [OPTIONS...] COMMAND [COMMAND_ARGS...] [COMMAND_OPTIONS...]
</code></pre><h1 id="options">Options</h1><ul><li><p><code class="inline-verbatim">--user</code> runs the binary in user mode with the user-specific options and load-path.
See <a href="/wiki/linux.systemd#systemd-at-user-level">systemd at user-level</a> for more details.
</p></li><li><p><code class="inline-verbatim">--help</code> is an obvious one.
It prints a detailed help section of the command.
</p></li></ul><h1 id="subcommands">Subcommands</h1><ul><li><p><code class="inline-verbatim">enable UNIT</code> and <code class="inline-verbatim">disable UNIT</code> enables and disables units.
It mainly adds the unit activation at startup.
</p><ul><li><p><code class="inline-verbatim">--now</code> starts/stops the unit.
It is the equivalent of <code class="inline-verbatim">systemctl {enable,disable} UNIT &amp;&amp; systemctl {start,stop} UNIT</code>.
Pretty handy if you intend to add the unit at startup and want to use it now.
</p></li></ul></li><li><p><code class="inline-verbatim">start UNIT</code> and <code class="inline-verbatim">stop UNIT</code> starts and stops the unit, respectively.
Though, this doesn&#x27;t activate
</p></li><li><p><code class="inline-verbatim">restart UNIT</code> restarts the given unit.
This also reloads with the modified changes of the unit.
</p></li><li><p>In some cases where restarting the unit isn&#x27;t enough, <code class="inline-verbatim">daemon-reload</code> will reload the daemon with the modified units.
systemd does not have reload-at-change for its unit.
That is, if a unit is modified, systemd will not run the modified version until reloaded.
</p></li><li><p><code class="inline-verbatim">show-environment</code> shows the environment variables of the system.
</p></li><li><p><code class="inline-verbatim">list-units [PATTERN...]</code> is self-explanatory ;p.
</p></li><li><p><code class="inline-verbatim">is-active PATTERN...</code> prints the status of the matched unit and exits successfully if it&#x27;s active.
</p></li></ul></main></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"metadata":{"date":"2021-07-27 13:47:34 +08:00","date_modified":"2021-07-27 14:06:35 +08:00","language":"en","source":""},"title":"Command line: systemctl","hast":{"type":"root","children":[{"type":"element","tagName":"nav","properties":{"className":"toc"},"children":[{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-1"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"synopsis"},"children":[{"type":"text","value":"Synopsis"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/cli.systemctl#synopsis"},"children":[{"type":"text","value":"Synopsis"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"options"},"children":[{"type":"text","value":"Options"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/cli.systemctl#options"},"children":[{"type":"text","value":"Options"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"subcommands"},"children":[{"type":"text","value":"Subcommands"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/cli.systemctl#subcommands"},"children":[{"type":"text","value":"Subcommands"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The go-to command to manage units in a systemd-ful system.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For full details, you can view the "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"systemctl.1"}]},{"type":"text","value":" manual page.\n"}]},{"type":"element","tagName":"h1","properties":{"id":"synopsis"},"children":[{"type":"text","value":"Synopsis"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-shell"]},"children":[{"type":"text","value":"systemctl [OPTIONS...] COMMAND [COMMAND_ARGS...] [COMMAND_OPTIONS...]\n"}]}]},{"type":"element","tagName":"h1","properties":{"id":"options"},"children":[{"type":"text","value":"Options"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"--user"}]},{"type":"text","value":" runs the binary in user mode with the user-specific options and load-path.\n See "},{"type":"element","tagName":"a","properties":{"href":"/linux.systemd#systemd-at-user-level"},"children":[{"type":"text","value":"systemd at user-level"}]},{"type":"text","value":" for more details.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"--help"}]},{"type":"text","value":" is an obvious one.\n It prints a detailed help section of the command.\n"}]}]}]},{"type":"element","tagName":"h1","properties":{"id":"subcommands"},"children":[{"type":"text","value":"Subcommands"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"enable UNIT"}]},{"type":"text","value":" and "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"disable UNIT"}]},{"type":"text","value":" enables and disables units.\n It mainly adds the unit activation at startup.\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"--now"}]},{"type":"text","value":" starts/stops the unit.\n It is the equivalent of "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"systemctl {enable,disable} UNIT \u0026\u0026 systemctl {start,stop} UNIT"}]},{"type":"text","value":".\n Pretty handy if you intend to add the unit at startup and want to use it now.\n"}]}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"start UNIT"}]},{"type":"text","value":" and "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"stop UNIT"}]},{"type":"text","value":" starts and stops the unit, respectively.\n Though, this doesn't activate\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"restart UNIT"}]},{"type":"text","value":" restarts the given unit.\n This also reloads with the modified changes of the unit.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In some cases where restarting the unit isn't enough, "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"daemon-reload"}]},{"type":"text","value":" will reload the daemon with the modified units.\n systemd does not have reload-at-change for its unit.\n That is, if a unit is modified, systemd will not run the modified version until reloaded.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"show-environment"}]},{"type":"text","value":" shows the environment variables of the system.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"list-units [PATTERN...]"}]},{"type":"text","value":" is self-explanatory ;p.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"is-active PATTERN..."}]},{"type":"text","value":" prints the status of the matched unit and exits successfully if it's active.\n"}]}]}]}]},"backlinks":[]},"__N_SSG":true},"page":"/[[...slug]]","query":{"slug":["cli.systemctl"]},"buildId":"Ie9t5zutrXP6Of75Cb5xF","assetPrefix":"/wiki","nextExport":false,"isFallback":false,"gsp":true}</script><script nomodule="" src="/wiki/_next/static/chunks/polyfills-99d808df29361cf7ffb1.js"></script><script src="/wiki/_next/static/chunks/main-ae4733327bd95c4ac325.js" async=""></script><script src="/wiki/_next/static/chunks/webpack-50bee04d1dc61f8adf5b.js" async=""></script><script src="/wiki/_next/static/chunks/framework.9d524150d48315f49e80.js" async=""></script><script src="/wiki/_next/static/chunks/commons.0e1c3f9aa780c2dfe9f0.js" async=""></script><script src="/wiki/_next/static/chunks/pages/_app-8e3d0c58a60ec788aa69.js" async=""></script><script src="/wiki/_next/static/chunks/940643274e605e7596ecea1f2ff8d83317a3fb76.4841a16762f602a59f00.js" async=""></script><script src="/wiki/_next/static/chunks/pages/%5B%5B...slug%5D%5D-1aa198f87ede1cd0e1dc.js" async=""></script><script src="/wiki/_next/static/Ie9t5zutrXP6Of75Cb5xF/_buildManifest.js" async=""></script><script src="/wiki/_next/static/Ie9t5zutrXP6Of75Cb5xF/_ssgManifest.js" async=""></script></body></html>