  <chapter id="oper">
    <title>Basic operation</title>
    <abstract>
      <para>This chapter describes basic operations done during everyday
      system administrator work. This operations are not much different
      then in other Linux based systems hence we concentrate on the
      specific for PLD ones.</para>
    </abstract>
    <section id="restart-shutdown">
      <title>Restarting and shutting down</title>
      <para>
	Traditional way of shutting down the machine is via <command>shutdown</command> 
	command, e.g.:
	<programlisting>shutdown -h now</programlisting></para>
      <para>
	But two simple commands can be used instead:
	<itemizedlist>
	  <listitem>
	    <para><command>halt</command> immediately runs shutdown procedure</para>
	  </listitem>
	  <listitem>
	    <para><command>reboot</command> immediately runs reboot procedure</para>
	  </listitem>
	</itemizedlist>
	On PC computers reboot can be also invoked by pressing Ctrl-Alt-Del sequence.
      </para>
    </section>
    
    <section id="subsystems">
      <title>Starting/stopping particular subsystems</title>
      <para>
	In every system there is a number of special tasks that needs
	to be performed (in proper order) at startup and shutdown.
	This usually involves setup (e.g. network setup, sound setup),
	as well as launching some services (e.g. http server, ssh server).
	The tasks that needs to be handled in that way are commonly referred to as
	subsystems or services.
      </para>
      <para>
	Running of particular subsystems/services can be easily
	controlled with system scripts. Each vital subsystem/service has its 
	driver script
	available in <filename>/etc/rc.d/init.d/</filename> directory.
	If you run script without parameters, it displays short info, e.g.
	<emphasis>network</emphasis> subsystem script displays:
	<programlisting>
# /etc/rc.d/init.d/network
Usage: /etc/rc.d/init.d/network {start|stop|restart|status}
	</programlisting>

	Most scripts support <emphasis>start</emphasis>, 
	<emphasis>stop</emphasis>, <emphasis>restart</emphasis>, 
	and <emphasis>status</emphasis> argument:
	<variablelist>
	  <varlistentry>
	    <term>start</term>
	    <listitem>
	      <para>runs the subsystem/service</para>
	    </listitem>
	  </varlistentry>
	  <varlistentry>
	    <term>stop</term>
	    <listitem>
	      <para>stops the subsystem/service</para>
	    </listitem>
	  </varlistentry>
	  <varlistentry>
	    <term>restart</term>
	    <listitem>
	      <para>restarts the subsystem/service</para>
	      <note>
		<para>
		  Usually this is equivalent to <emphasis>start</emphasis> 
		  and <emphasis>stop</emphasis>, but in some cases
		  it can be different.
		</para>
	      </note>
	    </listitem>
	  </varlistentry>
	  <varlistentry>
	    <term>status</term>
	    <listitem>
	      <para>shows the status of the subsystem/service</para>
	    </listitem>
	  </varlistentry>

	</variablelist>
      </para>
      <example>
	<title>Starting/stopping services</title>
	<para>
	  This example sequence stops and starts network again 
	  (turning on/off existing interfaces, setting default routing, etc. See
	  <xref linkend="network"/>)
	</para>
	<programlisting>
[root@pldmachine root]# /etc/rc.d/init.d/network stop
Shutting down interface eth0.......................................[ DONE ]
Shutting down interface eth1.......................................[ DONE ]
[root@pldmachine root]# /etc/rc.d/init.d/network start
Setting network parameters.........................................[ DONE ]
Bringing up interface eth0.........................................[ DONE ]
Bringing up interface eth1.........................................[ DONE ]
	</programlisting>
      </example>
      <para>
	Every subsystem script contains information in what runlevels
	that subsystem should be started by default with line like this
	(example line from <filename>/etc/rc.d/init.d/syslog</filename> subsystem):
	<programlisting># chkconfig:    2345 30 70></programlisting>
	This tells rc-scripts to run the subsystem when entering runlevels 
	2, 3, 4, 5 (and respectively, to stop subsystem when leaving one of these
	runlevels). Numbers 30 and 70 are priority levels for start/stop.
	See <citerefentry>
	  <refentrytitle>chkconfig</refentrytitle>
	  <manvolnum>8</manvolnum>
	</citerefentry> for details.
      </para>
      <para>
	Set of subsystems/services run in particular runlevel can be changed 
	with <command>chkconfig</command> command. 
	Some examples:
	<programlisting>
] # list current status
] # asterisks (***) means the service/subsys is started/stopped in runlevel
]
] chkconfig --list
gpm            	0:---	1:---	2:***	3:***	4:***	5:***	6:---
network        	0:---	1:---	2:***	3:***	4:***	5:***	6:---
httpd          	0:---	1:---	2:---	3:***	4:***	5:***	6:---
random         	0:---	1:***	2:***	3:***	4:***	5:***	6:---
qmail          	0:---	1:---	2:***	3:***	4:***	5:***	6:---
single         	0:---	1:***	2:---	3:---	4:---	5:---	6:---
klogd          	0:---	1:---	2:***	3:***	4:***	5:***	6:---
console        	0:---	1:---	2:---	3:***	4:***	5:***	6:---
sshd           	0:---	1:---	2:---	3:***	4:***	5:***	6:---
nfsfs          	0:---	1:---	2:---	3:***	4:***	5:***	6:---
timezone       	0:---	1:---	2:***	3:***	4:***	5:***	6:---
syslog         	0:---	1:---	2:***	3:***	4:***	5:***	6:---
rc-inetd       	0:---	1:---	2:---	3:***	4:***	5:***	6:---

] # exclude sshd service from runlevels 345
] chkconfig sshd off

] # include sshd service in runlevels 345 again
] chkconfig sshd on
	</programlisting>

	<note>
	  <para>
	    Removing/adding service to runlevel takes effect next time the 
	    runlevel is changed.
	    It does not automatically start subsystem if one is not running,
	    or stop it if it's already running.
	  </para>
	</note>

      </para>
    </section>
    <section id="runlevels">
      <title>Changing runlevels</title>
      <para>
	PLD system can be run in several <emphasis>runlevels</emphasis>:
      </para>
      <variablelist>
	<varlistentry>
	  <term>Runlevel 1</term>
	  <listitem>
	    <para>
	      Single user mode. Used by administrator for rescue/emergency/system
	      maintenance reasons.
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term>Runlevel 2</term>
	  <listitem>
	    <para>
	      Multiuser level, but without Network File System
	    </para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term>Runlevel 3</term>
	  <listitem>
	    <para>
	      Normal multiuser level. This is most commonly used runlevel.</para>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term>Runlevel 5</term>
	  <listitem>
	    <para>
	      Normal multiuser level with X Window environment started by default.
	      This is popular choice for workstations.
	    </para>
	  </listitem>
	</varlistentry>
      </variablelist>
      
      <para>
	There are two more runlevels: these are Runlevel 0 and Runlevel 6.
	First one is used to bring all subsystems/processes down before system halt,
	second is used to accomplish similar task before system reboot.
      </para>      
      <para>
	System boots up in <emphasis>default runlevel</emphasis> that is
	defined in <filename>/etc/inittab</filename> (see <xref linkend="inittab"/>) 
	which is usually 3 or 5.
	Current runlevel can be changed with <command>telinit</command> command.
	For example, if system is running level 3, issuing <command>telinit 2</command>
	brings it to level 2 (as a consequence, NFS subsystems will be stopped).
      </para>
    </section>

	&managing;

	
    </chapter>

<!-- Keep this comment at the end of the file
Local variables:
mode: xml
sgml-omittag:nil
sgml-shorttag:nil
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:2
sgml-indent-data:t
sgml-default-dtd-file:"../dbxbook4.1.2.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
sgml-declaration:nil
sgml-validate-command:"rxp -sxV %s %s"
sgml-parent-document:("PLD-Guide.xml" "book" "section")
End:
-->
