old-www/LDP/GNU-Linux-Tools-Summary/html/x6066.htm

462 lines
5.9 KiB
HTML

<HTML
><HEAD
><TITLE
>Controlling services</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="GNU/Linux Command-Line Tools Summary"
HREF="book1.htm"><LINK
REL="UP"
TITLE="Controlling the system"
HREF="c4975.htm"><LINK
REL="PREVIOUS"
TITLE="Controlling Processes"
HREF="x5368.htm"><LINK
REL="NEXT"
TITLE="Managing users"
HREF="c6239.htm"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>GNU/Linux Command-Line Tools Summary</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x5368.htm"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 9. Controlling the system</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="c6239.htm"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="CONTROLLING-SERVICES"
></A
>Controlling services</H1
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>Concept&nbsp;Definitions<A
NAME="SERVICES-CONCEPT"
></A
></DT
><DD
><P
>&nbsp;</P
><P
>UNIX <A
NAME="AEN6075"
></A
>systems use scripts <A
NAME="AEN6077"
></A
>to control <A
NAME="AEN6079"
></A
>&ldquo;daemons&rdquo; which provide <A
NAME="AEN6081"
></A
>&ldquo;services&rdquo; (for example your sound <A
NAME="AEN6083"
></A
>output) to run a <SPAN
CLASS="PRODUCTNAME"
>UNIX</SPAN
> system. <SPAN
CLASS="PRODUCTNAME"
>UNIX</SPAN
> systems consist of a variety <A
NAME="AEN6087"
></A
>of services <A
NAME="AEN6089"
></A
>(daemons).</P
><P
>A &ldquo;daemon&rdquo; is a system process which runs in the background <A
NAME="AEN6092"
></A
>(zero interaction) performing<A
NAME="AEN6094"
></A
> a particular task.<A
NAME="AEN6096"
></A
></P
><P
>Daemons <A
NAME="AEN6099"
></A
>normally have a &ldquo;d&rdquo; on the end of their name and either listen <A
NAME="AEN6101"
></A
>for certain events <A
NAME="AEN6103"
></A
>or perform<A
NAME="AEN6105"
></A
> a system task,<A
NAME="AEN6107"
></A
> for example <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>sshd</I
></SPAN
> listens <A
NAME="AEN6110"
></A
>for secure shell requests to the particular <A
NAME="AEN6112"
></A
>machine <A
NAME="AEN6114"
></A
>and handles<A
NAME="AEN6116"
></A
> them when they occur.</P
><P
>Daemons usually perform critical <A
NAME="AEN6119"
></A
>system tasks <A
NAME="AEN6121"
></A
>such as control <A
NAME="AEN6123"
></A
>swap-space, memory <A
NAME="AEN6125"
></A
>management <A
NAME="AEN6127"
></A
>and various other tasks.<A
NAME="AEN6129"
></A
></P
></DD
><DT
>service</DT
><DD
><P
><A
NAME="AEN6135"
></A
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>service</I
></SPAN
> is a shell script available <A
NAME="AEN6138"
></A
>on Mandrake/Mandriva<A
NAME="AEN6140"
></A
><A
NAME="AEN6142"
></A
> and Redhat <A
NAME="AEN6144"
></A
>systems which allows <A
NAME="AEN6146"
></A
>you to perform various tasks <A
NAME="AEN6148"
></A
>on services.<A
NAME="AEN6150"
></A
> </P
><P
></P
><UL
><LI
><P
>Use the <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>-s<A
NAME="AEN6156"
></A
></I
></SPAN
> option to print <A
NAME="AEN6158"
></A
>the status <A
NAME="AEN6160"
></A
>of all services <A
NAME="AEN6162"
></A
>available <A
NAME="AEN6164"
></A
></P
></LI
><LI
><P
>Use the <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>-f<A
NAME="AEN6169"
></A
></I
></SPAN
> option followed <A
NAME="AEN6171"
></A
>by a service <A
NAME="AEN6173"
></A
>name to restart <A
NAME="AEN6175"
></A
>that particular service. </P
></LI
><LI
><P
>Use the <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>-R<A
NAME="AEN6180"
></A
></I
></SPAN
> option to restart <A
NAME="AEN6182"
></A
>all services <A
NAME="AEN6184"
></A
>(note that this will kill <A
NAME="AEN6186"
></A
>any current services running,<A
NAME="AEN6188"
></A
> including the X windows system).</P
></LI
></UL
><P
>For example to restart <A
NAME="AEN6191"
></A
>the daemon <A
NAME="AEN6193"
></A
><SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
> sshd <A
NAME="AEN6196"
></A
></I
></SPAN
>you would type:</P
><PRE
CLASS="SCREEN"
>service -f sshd</PRE
></DD
><DT
>Using&nbsp;the&nbsp;script&nbsp;directly</DT
><DD
><P
>You may also execute the shell script directly from <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>/etc/init.d</I
></SPAN
><A
NAME="AEN6204"
></A
>. Simply go to that directory <A
NAME="AEN6206"
></A
>then type <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>./script_name</I
></SPAN
>.</P
><P
>Executing the script <A
NAME="AEN6210"
></A
>should return <A
NAME="AEN6212"
></A
>the options it can take, by default <A
NAME="AEN6214"
></A
>they will be:</P
><P
></P
><UL
><LI
><P
>restart <A
NAME="AEN6219"
></A
>--- this will make the service <A
NAME="AEN6221"
></A
>stop <A
NAME="AEN6223"
></A
>and then start again.</P
></LI
><LI
><P
>start --- this option <A
NAME="AEN6227"
></A
>will start a service (assuming its not running).</P
></LI
><LI
><P
>stop --- this option will stop a service (assuming its running).</P
></LI
><LI
><P
>status <A
NAME="AEN6233"
></A
>--- this option will tell <A
NAME="AEN6235"
></A
>you about the service<A
NAME="AEN6237"
></A
></P
></LI
></UL
></DD
></DL
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x5368.htm"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.htm"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="c6239.htm"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Controlling Processes</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c4975.htm"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Managing users</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>