systemd-custom.xml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  4. <!ENTITY % general-entities SYSTEM "../general.ent">
  5. %general-entities;
  6. ]>
  7. <sect1 id="ch-scripts-systemd-custom">
  8. <?dbhtml filename="systemd-custom.html"?>
  9. <title>Systemd Usage and Configuration</title>
  10. <indexterm zone="ch-scripts-systemd-custom">
  11. <primary sortas="e-Systemd">Systemd Customization</primary>
  12. </indexterm>
  13. <sect2>
  14. <title>Basic Configuration</title>
  15. <para>The <filename>/etc/systemd/system.conf</filename> file contains a set
  16. of options to control basic systemd operations. The default file has all
  17. entries commented out with the default settings indicated. This file is
  18. where the log level may be changed as well as some basic logging settings.
  19. See <filename>systemd-system.conf(5)</filename> manual page for details on
  20. each configuration option.</para>
  21. </sect2>
  22. <sect2>
  23. <title>Disabling Screen Clearing at Boot Time</title>
  24. <para>The normal behavior for systemd is to clear the screen at
  25. the end of the boot sequence. If desired, this behavior may be
  26. changed by running the following command:</para>
  27. <screen role="nodump"><userinput>mkdir -pv /etc/systemd/system/getty@tty1.service.d
  28. cat &gt; /etc/systemd/system/getty@tty1.service.d/noclear.conf &lt;&lt; EOF
  29. <literal>[Service]
  30. TTYVTDisallocate=no</literal>
  31. EOF</userinput></screen>
  32. <para>The boot messages can always be revied by using the
  33. <userinput>journalctl -b</userinput> command as the root user.</para>
  34. </sect2>
  35. <sect2>
  36. <title>Disabling tmpfs for /tmp</title>
  37. <para>By default, <filename class="directory">/tmp</filename> is created as
  38. a tmpfs. If this is not desired, it can be overridden by the following:</para>
  39. <screen role="nodump"><userinput>ln -sfv /dev/null /etc/systemd/system/tmp.mount</userinput></screen>
  40. <para>This is not necessary if there is a separate partition for
  41. <filename class="directory">/tmp</filename> specified in
  42. <filename>/etc/fstab</filename>.</para>
  43. </sect2>
  44. <sect2>
  45. <title>Configuring Automatic File Creation and Deletion</title>
  46. <para>There are several services that create or delete files or
  47. directories:</para>
  48. <itemizedlist>
  49. <listitem><para>systemd-tmpfiles-clean.service</para></listitem>
  50. <listitem><para>systemd-tmpfiles-setup-dev.service</para></listitem>
  51. <listitem><para>systemd-tmpfiles-setup.service</para></listitem>
  52. </itemizedlist>
  53. <para>The system location for the configuration files is
  54. <filename>/usr/lib/tmpfiles.d/*.conf</filename>. The local
  55. configuration files are in
  56. <filename class="directory">/etc/tmpfiles.d</filename>. Files in
  57. <filename class="directory">/etc/tmpfiles.d</filename> override
  58. files with the same name in
  59. <filename class="directory">/usr/lib/tmpfiles.d</filename>. See
  60. <filename>tmpfiles.d(5)</filename> manual page for file format
  61. details.</para>
  62. </sect2>
  63. <sect2>
  64. <title>Overriding Default Services Behavior</title>
  65. <para>A systemd service contents can be overriden by creating a directory
  66. and a configuration file in <filename
  67. class="directory">/etc/systemd/system</filename>. For example:</para>
  68. <screen role="nodump"><userinput>mkdir -pv /etc/systemd/system/foobar.service.d
  69. cat > /etc/systemd/system/foobar.service.d/foobar.conf &lt;&lt; EOF
  70. <literal>[Service]
  71. Restart=always
  72. RestartSec=30</literal>
  73. EOF</userinput></screen>
  74. <para>See <filename>systemd.unit(5)</filename> manual page for more
  75. information. After creating the configuration file, run
  76. <userinput>systemctl daemon-reload</userinput> and <userinput>systemctl
  77. restart foobar</userinput> to activate the changes to a service.</para>
  78. </sect2>
  79. <sect2>
  80. <title>Debugging the Boot Sequence</title>
  81. <para>Rather than plain shell scripts used in SysVinit or BSD style init
  82. systems, systemd uses a unified format for different type of startup
  83. files (or units). The command <command>systemctl</command> is used to
  84. enable, disable, controll state, and obtain status of unit files. Here
  85. are some examples of frequently used commands:</para>
  86. <itemizedlist>
  87. <listitem>
  88. <para><command>systemctl list-units -t <replaceable>&lt;service&gt;</replaceable> [--all]</command>:
  89. lists loaded unit files of type service.</para>
  90. </listitem>
  91. <listitem>
  92. <para><command>systemctl list-units -t <replaceable>&lt;target&gt;</replaceable> [--all]</command>:
  93. lists loaded unit files of type target.</para>
  94. </listitem>
  95. <listitem>
  96. <para><command>systemctl show -p Wants <replaceable>&lt;multi-user.target&gt;</replaceable></command>:
  97. shows all units that depend on the multi-user target. Targets are
  98. special unit files that are anogalous to runlevels under
  99. SysVinit.</para>
  100. </listitem>
  101. <listitem>
  102. <para><command>systemctl status <replaceable>&lt;servicename.service&gt;</replaceable></command>:
  103. shows the status of the servicename service. The .service extension
  104. can be omitted if there are no other unit files with the same name,
  105. such as .socket files (which create a listening socket that provides
  106. similar functionality to inetd/xinetd).</para>
  107. </listitem>
  108. </itemizedlist>
  109. </sect2>
  110. <sect2>
  111. <title>Working with the Systemd Journal</title>
  112. <para>Logging on a system booted with systemd is handled by
  113. systemd-journald (default), rather than a typical unix syslog daemon.
  114. systemd-journald write log entries to a binary file format, rather than
  115. a plain text log file. To assist with parsing the file, the command
  116. <command>journalctl</command> is provided. Here are some examples of
  117. frequently used commands:</para>
  118. <itemizedlist>
  119. <listitem>
  120. <para><command>journalctl -r</command>: shows all contents of the
  121. journal in reverse chronological order.</para>
  122. </listitem>
  123. <listitem>
  124. <para><command>journalctl -u <replaceable>UNIT</replaceable></command>:
  125. shows the journal entries associated with the specified UNIT
  126. file.</para>
  127. </listitem>
  128. <listitem>
  129. <para><command>journalctl -b[=ID] -r</command>: shows the journal
  130. entries since last successfull boot (or for boot ID) in reverse
  131. chronological order.</para>
  132. </listitem>
  133. <listitem>
  134. <para><command>journalctl -f</command>: povides functionality similar
  135. to tail -f (follow).</para>
  136. </listitem>
  137. </itemizedlist>
  138. </sect2>
  139. </sect1>