1<HTML> 2<HEAD> 3<TITLE> 4[Chapter 2] 2.5 Starting the Samba Daemons</title><META NAME="DC.title" CONTENT=""><META NAME="DC.creator" CONTENT=""><META NAME="DC.publisher" CONTENT="O'Reilly & Associates, Inc."><META NAME="DC.date" CONTENT="1999-11-05T21:29:11Z"><META NAME="DC.type" CONTENT="Text.Monograph"><META NAME="DC.format" CONTENT="text/html" SCHEME="MIME"><META NAME="DC.source" CONTENT="" SCHEME="ISBN"><META NAME="DC.language" CONTENT="en-US"><META NAME="generator" CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"></head> 5<BODY BGCOLOR="#FFFFFF" TEXT="#000000" link="#990000" vlink="#0000CC"> 6<table BORDER="0" CELLPADDING="0" CELLSPACING="0" width="90%"> 7<tr> 8<td width="25%" valign="TOP"> 9<img hspace=10 vspace=10 src="gifs/samba.s.gif" 10alt="Using Samba" align=left valign=top border=0> 11</td> 12<td height="105" valign="TOP"> 13<br> 14<H2>Using Samba</H2> 15<font size="-1"> 16Robert Eckstein, David Collier-Brown, Peter Kelly 17<br>1st Edition November 1999 18<br>1-56592-449-5, Order Number: 4495 19<br>416 pages, $34.95 20</font> 21<p> <a href="http://www.oreilly.com/catalog/samba/">Buy the hardcopy</a> 22<p><a href="index.html">Table of Contents</a> 23</td> 24</tr> 25</table> 26<hr size=1 noshade> 27<!--sample chapter begins --> 28 29<center> 30<DIV CLASS="htmlnav"> 31<TABLE WIDTH="515" BORDER="0" CELLSPACING="0" CELLPADDING="0"> 32<TR> 33<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 34<A CLASS="sect1" HREF="ch02_04.html" TITLE="2.4 A Basic Samba Configuration File"> 35<IMG SRC="gifs/txtpreva.gif" ALT="Previous: 2.4 A Basic Samba Configuration File" BORDER="0"></a></td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 36<B> 37<FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1"> 38<A CLASS="chapter" REL="up" HREF="ch02_01.html" TITLE="2. Installing Samba on a Unix System"> 39Chapter 2<br> 40Installing Samba on a Unix System</a></font></b></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 41<A CLASS="sect1" HREF="ch02_06.html" TITLE="2.6 Testing the Samba Daemons"> 42<IMG SRC="gifs/txtnexta.gif" ALT="Next: 2.6 Testing the Samba Daemons" BORDER="0"></a></td></tr></table> <hr noshade size=1></center> 43</div> 44<blockquote> 45<div> 46<H2 CLASS="sect1"> 47<A CLASS="title" NAME="ch02-29069"> 482.5 Starting the Samba Daemons</a></h2><P CLASS="para"> 49There are two Samba processes, <EM CLASS="emphasis"> 50smbd</em> and <EM CLASS="emphasis"> 51nmbd</em>, that need to be running for Samba to work correctly. There are three ways to start:</p><UL CLASS="itemizedlist"> 52<LI CLASS="listitem"> 53<P CLASS="para"> 54<A CLASS="listitem" NAME="ch02-pgfId-943268"> 55</a>By hand</p></li><LI CLASS="listitem"> 56<P CLASS="para"> 57<A CLASS="listitem" NAME="ch02-pgfId-943266"> 58</a>As stand-alone daemons</p></li><LI CLASS="listitem"> 59<P CLASS="para"> 60<A CLASS="listitem" NAME="ch02-pgfId-947794"> 61</a>From <EM CLASS="emphasis"> 62inetd</em></p></li></ul><DIV CLASS="sect2"> 63<H3 CLASS="sect2"> 64<A CLASS="title" NAME="ch02-pgfId-938883"> 652.5.1 Starting the Daemons by Hand</a></h3><P CLASS="para"> 66If you're in a hurry, you can start the Samba daemons by hand. As root, simply enter the following commands:</p><PRE CLASS="programlisting"> 67#<CODE CLASS="userinput"> <B>/usr/local/samba/bin/smbd -D</b></code> 68#<CODE CLASS="userinput"> <B>/usr/local/samba/bin/nmbd -D</b></code></pre><P CLASS="para"> 69At this point, Samba will be running on your system and will be ready to accept connections.</p></div><DIV CLASS="sect2"> 70<H3 CLASS="sect2"> 71<A CLASS="title" NAME="ch02-pgfId-943275"> 722.5.2 Stand-alone Daemons</a></h3><P CLASS="para"> 73To run the Samba processes as stand-alone daemons, you need to add the commands listed in the previous section to your standard Unix startup scripts. This varies depending on whether you have a BSD-style Unix system or a System V Unix.</p><DIV CLASS="sect3"> 74<H4 CLASS="sect3"> 75<A CLASS="title" NAME="ch02-pgfId-947593"> 762.5.2.1 BSD Unix</a></h4><P CLASS="para"> 77WIth a BSD-style Unix, you need to append the following code to the <I CLASS="filename"> 78rc.local </i>file, which is typically found in the <I CLASS="filename"> 79/etc</i> or <I CLASS="filename"> 80/etc/rc.d</i> directories:</p><PRE CLASS="programlisting"> 81if [ -x /usr/local/samba/bin/smbd]; then 82 echo "Starting smbd..." 83 /usr/local/samba/bin/smbd -D 84 echo "Starting nmbd..." 85 /usr/local/samba/bin/nmbd -D 86fi</pre><P CLASS="para"> 87This code is very simple; it checks to see if the <I CLASS="filename"> 88smbd</i> file has execute permissions on it, and if it does, it starts up each of the Samba daemons on system boot.</p></div><DIV CLASS="sect3"> 89<H4 CLASS="sect3"> 90<A CLASS="title" NAME="ch02-pgfId-943333"> 912.5.2.2 System V Unix</a></h4><P CLASS="para"> 92With System V, things can get a little more complex. System V typically uses scripts to start and stop daemons on the system. Hence, you need to instruct Samba how to operate when it starts and when it stops. You can modify the contents of the <I CLASS="filename"> 93/etc/rc.local</i> directory and add something similar to the following program entitled <I CLASS="filename"> 94smb</i>:</p><PRE CLASS="programlisting"> 95#!/bin/sh 96 97# Contains the "killproc" function on Red Hat Linux 98./etc/rc.d/init.d/functions 99 100PATH="/usr/local/samba/bin:$PATH" 101 102case $1 in 103 'start') 104 echo "Starting smbd..." 105 smbd -D 106 echo "Starting nmbd..." 107 nmbd -D 108 ;; 109 'stop') 110 echo "Stopping smbd and nmbd..." 111 killproc smbd 112 killproc nmbd 113 rm -f /usr/local/samba/var/locks/smbd.pid 114 rm -f /usr/local/samba/var/locks/nmbd.pid 115 ;; 116 *) 117 echo "usage: smb {start|stop}" 118 ;; 119esac</pre><P CLASS="para"> 120With this script, you can start and stop the SMB service with the following commands:</p><PRE CLASS="programlisting"> 121# /etc/rc.local/smb start 122Starting smbd... 123Starting nmbd... 124# /etc/rc.local/smb stop 125Stopping smbd and nmbd...</pre></div></div><DIV CLASS="sect2"> 126<H3 CLASS="sect2"> 127<A CLASS="title" NAME="ch02-pgfId-943302"> 1282.5.3 Starting From Inetd</a></h3><P CLASS="para"> 129The <EM CLASS="emphasis"> 130inetd</em> daemon is a Unix system's Internet "super daemon." It listens on TCP ports defined in <I CLASS="filename"> 131/etc/services</i> and executes the appropriate program for each port, which is defined in <I CLASS="filename"> 132/etc/inetd.conf</i>. The advantage of this scheme is that you can have a large number of daemons ready to answer queries, but they don't all have to be running. Instead, the <EM CLASS="emphasis"> 133inetd</em> daemon listens in places of all the others. The penalty is a small overhead cost of creating a new daemon process, and the fact that you need to edit two files rather than one to set things up. This is handy if you have only one or two users or your machine has too many daemons already. It's also easier to perform an upgrade without disturbing an existing connection.</p><P CLASS="para"> 134If you wish to start from <I CLASS="filename"> 135inetd</i>, first open <I CLASS="filename"> 136/etc/services</i> in your text editor. If you don't already have them defined, add the following two lines:</p><PRE CLASS="programlisting"> 137netbios-ssn 139/tcp 138netbios-ns 137/udp</pre><P CLASS="para"> 139Next, edit <I CLASS="filename"> 140/etc/inetd.conf</i>. Look for the following two lines and add them if they don't exist. If you already have <CODE CLASS="literal"> 141smbd</code> and <CODE CLASS="literal"> 142nmbd</code> lines in the file, edit them to point at the new <EM CLASS="emphasis"> 143smbd</em> and <EM CLASS="emphasis"> 144nmbd</em> you've installed. Your brand of Unix may use a slightly different syntax in this file; use the existing entries and the <I CLASS="filename"> 145inetd.conf </i><KBD CLASS="command"></kbd>manual page <KBD CLASS="command"></kbd>as a guide:</p><PRE CLASS="programlisting"> 146netbios-ssn stream tcp nowait root /usr/local/samba/bin/smbd smbd 147netbios-ns dgram udp wait root /usr/local/samba/bin/nmbd nmbd</pre><P CLASS="para"> 148Finally, kill any <EM CLASS="emphasis"> 149smbd</em> or <EM CLASS="emphasis"> 150nmbd</em> processes and send the <EM CLASS="emphasis"> 151inetd</em> process a hangup (HUP) signal. (The <EM CLASS="emphasis"> 152inetd</em> daemon rereads its configuration file on a HUP signal.) To do this, use the <CODE CLASS="literal"> 153ps</code> command to find its process ID, then signal it with the following command:</p><PRE CLASS="programlisting"> 154# <CODE CLASS="userinput"><B>kill -HUP process_id</b></code></pre><P CLASS="para"> 155After that, Samba should be up and running. </p></div></div></blockquote> 156<div> 157<center> 158<hr noshade size=1><TABLE WIDTH="515" BORDER="0" CELLSPACING="0" CELLPADDING="0"> 159<TR> 160<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 161<A CLASS="sect1" HREF="ch02_04.html" TITLE="2.4 A Basic Samba Configuration File"> 162<IMG SRC="gifs/txtpreva.gif" ALT="Previous: 2.4 A Basic Samba Configuration File" BORDER="0"></a></td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 163<A CLASS="book" HREF="index.html" TITLE=""> 164<IMG SRC="gifs/txthome.gif" ALT="" BORDER="0"></a></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 165<A CLASS="sect1" HREF="ch02_06.html" TITLE="2.6 Testing the Samba Daemons"> 166<IMG SRC="gifs/txtnexta.gif" ALT="Next: 2.6 Testing the Samba Daemons" BORDER="0"></a></td></tr><TR> 167<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 1682.4 A Basic Samba Configuration File</td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 169<A CLASS="index" HREF="inx.html" TITLE="Book Index"> 170<IMG SRC="gifs/index.gif" ALT="Book Index" BORDER="0"></a></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 1712.6 Testing the Samba Daemons</td></tr></table><hr noshade size=1></center> 172</div> 173 174<!-- End of sample chapter --> 175<CENTER> 176<FONT SIZE="1" FACE="Verdana, Arial, Helvetica"> 177<A HREF="http://www.oreilly.com/"> 178<B>O'Reilly Home</B></A> <B> | </B> 179<A HREF="http://www.oreilly.com/sales/bookstores"> 180<B>O'Reilly Bookstores</B></A> <B> | </B> 181<A HREF="http://www.oreilly.com/order_new/"> 182<B>How to Order</B></A> <B> | </B> 183<A HREF="http://www.oreilly.com/oreilly/contact.html"> 184<B>O'Reilly Contacts<BR></B></A> 185<A HREF="http://www.oreilly.com/international/"> 186<B>International</B></A> <B> | </B> 187<A HREF="http://www.oreilly.com/oreilly/about.html"> 188<B>About O'Reilly</B></A> <B> | </B> 189<A HREF="http://www.oreilly.com/affiliates.html"> 190<B>Affiliated Companies</B></A><p> 191<EM>© 1999, O'Reilly & Associates, Inc.</EM> 192</FONT> 193</CENTER> 194</BODY> 195</html> 196