• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt/router/samba/docs/htmldocs/using_samba/
1<HTML>
2<HEAD>
3<TITLE>
4[Chapter 2] 2.4 A Basic Samba Configuration File</title><META NAME="DC.title" CONTENT=""><META NAME="DC.creator" CONTENT=""><META NAME="DC.publisher" CONTENT="O'Reilly &amp; Associates, Inc."><META NAME="DC.date" CONTENT="1999-11-05T21:29:10Z"><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_03.html" TITLE="2.3 Compiling and Installing Samba">
35<IMG SRC="gifs/txtpreva.gif" ALT="Previous: 2.3 Compiling and Installing Samba" 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_05.html" TITLE="2.5 Starting the Samba Daemons">
42<IMG SRC="gifs/txtnexta.gif" ALT="Next: 2.5 Starting the Samba Daemons" BORDER="0"></a></td></tr></table>&nbsp;<hr noshade size=1></center>
43</div>
44<blockquote>
45<div>
46<H2 CLASS="sect1">
47<A CLASS="title" NAME="ch02-13464">
482.4 A Basic Samba Configuration File</a></h2><P CLASS="para">
49The key to configuring Samba is its lone configuration file: <I CLASS="filename">
50smb.conf</i>. This configuration file can be very simple or extremely complex, and the rest of this book is devoted to helping you get deeply personal with this file. For now, however, we'll show you how to set up a single file service, which will allow you to fire up the Samba daemons and see that everything is running as it should be. In later chapters, you will see how to configure Samba for more complicated and interesting tasks. </p><P CLASS="para">
51The installation process does not automatically create an <I CLASS="filename">
52smb.conf</i> configuration file, although several example files are included in the Samba distribution. To test the server software, though, we'll use the following file. It should be named <I CLASS="filename">
53smb.conf</i> and placed in the <EM CLASS="emphasis">
54/usr/local/samba/lib</em> directory.[<A CLASS="footnote" HREF="#ch02-pgfId-943223">5</a>]</p><BLOCKQUOTE CLASS="footnote">
55<DIV CLASS="footnote">
56<P CLASS="para">
57<A CLASS="footnote" NAME="ch02-pgfId-943223">[5]</a> If you did not compile Samba, but instead downloaded a binary, check with the documentation for the package to find out where it expects the <I CLASS="filename">
58smb.conf</i> file. If Samba came preinstalled with your Unix system, there is probably already an <I CLASS="filename">
59smb.conf</i> file somewhere on your system.</p></div></blockquote><PRE CLASS="programlisting">
60[global]
61	workgroup = SIMPLE 
62[test] 
63	comment = For testing only, please
64	path = /export/samba/test
65	read only = no
66	guest ok = yes</pre><P CLASS="para">
67This brief configuration file tells the Samba server to offer the directory <I CLASS="filename">
68/export/samba/test</i> on the server as an SMB/CIFS share called <CODE CLASS="literal">test</code>. The server also becomes part of the named workgroup SIMPLE, which each of the clients must also be a part of. (Use your own workgroup here if you already know what it is.) We'll use the <CODE CLASS="literal">
69[test]</code> share in the next chapter to set up the Windows clients. For now, you can complete the setup by performing the following commands as root on your Unix server:</p><PRE CLASS="programlisting"># <CODE CLASS="userinput"><B>mkdir /export/samba/test</b></code>
70# <CODE CLASS="userinput"><B>chmod 777 /export/samba/test</b></code></pre><P CLASS="para">
71We should point out that in terms of system security, this is the worst setup possible. For the moment, however, we only wish to test Samba, so we'll leave security out of the picture. In addition, there are some encrypted password issues that we will encounter with Windows clients later on, so this setup will afford us the least amount of headaches.</p><P CLASS="para">
72If you are using Windows 98 or Windows NT Service Pack 3 or above, you must add the following entry to the <CODE CLASS="literal">
73[global]</code> section of the Samba configuration file: <CODE CLASS="literal">
74encrypt passwords = yes</code>. In addition, you must use the <I CLASS="filename">
75smbpassword</i> program (typically located in    <I CLASS="filename">
76/usr/local/samba/bin/</i>) to reenter the username/password combinations of those users on the Unix server who should be able to access shares into Samba's encrypted client database. For example, if you wanted to allow Unix user <CODE CLASS="literal">
77steve</code> to access shares from an SMB client, you could type: <CODE CLASS="literal">
78smbpassword -a steve</code>. The first time a user is added, the program will output an error saying that the encrypted password database does not exist. Don't worry, it will then create the database for you. Make sure that the username/password combinations that you add to the encrypted database match the usernames and passwords that you intend to use on the Windows client side.</p><DIV CLASS="sect2">
79<H3 CLASS="sect2">
80<A CLASS="title" NAME="ch02-pgfId-942383">
812.4.1 Using SWAT</a></h3><P CLASS="para">With Samba 2.0, creating a configuration file is even easier than writing a configuration file by hand. You can use your browser to connect to <a href="http://localhost:901"><EM CLASS="emphasis">http://localhost:901</em></a>, and log on as the root account, as shown in <A CLASS="xref" HREF="ch02_04.html#ch02-60915">
82Figure 2.1</a>. </p><H4 CLASS="figure">
83<A CLASS="title" NAME="ch02-60915">
84Figure 2.1: SWAT login</a></h4><IMG CLASS="graphic" SRC="figs/sam.0201.gif" ALT="Figure 2.1"><P CLASS="para">
85After logging in, press the GLOBALS button at the top of the screen. You should see the Global Variables page shown in <A CLASS="xref" HREF="ch02_04.html#ch02-49138">
86Figure 2.2</a>. </p><H4 CLASS="figure">
87<A CLASS="title" NAME="ch02-49138">
88Figure 2.2: SWAT Global Variables page</a></h4><IMG CLASS="graphic" SRC="figs/sam.0202.gif" ALT="Figure 2.2"><P CLASS="para">
89In this example, set the workgroup field to SIMPLE and the security field to USER. The only other option you need to change from the menu is one determining which system on the LAN resolves NetBIOS addresses; this system is called the <EM CLASS="emphasis">
90WINS server</em>. At the very bottom of the page, set the wins support field to Yes, unless you already have a WINS server on your network. If you do, put the WINS server's IP address in the wins server field instead. Then return to the top and press the Commit Changes button to write the changes out to the <EM CLASS="emphasis">
91smb.conf</em> file.  </p><H4 CLASS="figure">
92<A CLASS="title" NAME="ch02-29175">
93Figure 2.3: SWAT Share Creation screen</a></h4><IMG CLASS="graphic" SRC="figs/sam.0203.gif" ALT="Figure 2.3"><P CLASS="para">
94Next, press the Shares icon. You should see a page similar to <A CLASS="xref" HREF="ch02_04.html#ch02-29175">
95Figure 2.3</a>. Choose Test in the field beside the Choose Share button. You will see the Share Parameters screen, as shown in <A CLASS="xref" HREF="ch02_04.html#ch02-37186">
96Figure 2.4</a>. We added a comment to remind us that this is a test share in the <I CLASS="filename">
97smb.conf</i> file. SWAT has copies of all that information here.</p><H4 CLASS="figure">
98<A CLASS="title" NAME="ch02-37186">
99Figure 2.4: SWAT Share Parameters screen</a></h4><IMG CLASS="graphic" SRC="figs/sam.0204.gif" ALT="Figure 2.4"><P CLASS="para">
100If you press the View button, SWAT shows you the following <I CLASS="filename">
101smb.conf</i> file:</p><PRE CLASS="programlisting">
102# Samba config file created using SWAT
103# from localhost (127.0.0.1)
104# Date: 1998/11/27 15:42:40
105
106# Global parameters
107        workgroup = SIMPLE
108[test]
109        comment = For testing only, please
110        path = /export/samba/test
111        read only = no
112        guest ok = yes</pre><P CLASS="para">
113Once this configuration file is completed, you can skip the next step because the output of SWAT is guaranteed to be syntactically correct. </p></div><DIV CLASS="sect2">
114<H3 CLASS="sect2">
115<A CLASS="title" NAME="ch02-pgfId-938862">
1162.4.2 Testing the Configuration File</a></h3><P CLASS="para">If you didn't use SWAT to create your configuration file, you should probably test it to ensure that it is syntactically correct. It may seem silly to run a test program against an eight-line configuration file, but it's good practice for the real ones that we'll be writing later on.</p><P CLASS="para">
117The test parser, <I CLASS="filename">
118testparm</i>, examines an <I CLASS="filename">
119smb.conf</i> file for syntax errors and reports any it finds along with a list of the services enabled on your machine. An example follows; you'll notice that in our haste to get the server running we mistyped <CODE CLASS="literal">
120workgroup</code> as <CODE CLASS="literal">
121workgrp</code> (the output is often lengthy, so we recommend capturing the last parts with the <CODE CLASS="literal">
122tee</code> command):</p><PRE CLASS="programlisting">
123Load smb config files from smb.conf
124Unknown parameter encountered: &quot;workgrp&quot;
125Ignoring unknown parameter &quot;workgrp&quot;
126Processing section &quot;[test]&quot;
127Loaded services file OK.
128Press enter to see a dump of your service definitions
129# Global parameters
130[global]
131        workgroup = WORKGROUP
132        netbios name = 
133        netbios aliases = 
134        server string = Samba 2.0.5a
135        interfaces = 
136        bind interfaces only = No
137
138<I CLASS="lineannotation">...(content omitted)...</i>
139
140[test]
141        comment = For testing only, please               
142	path = /export/samba/test
143        read only = No
144        guest ok = Yes</pre><P CLASS="para">
145The interesting parts are at the top and bottom. The top of the output will flag any syntax errors that you may have made, and the bottom lists the services that the server thinks it should offer. A word of advice: make sure that you and the server have the same expectations. </p><P CLASS="para">
146If everything looks good, then you are ready to fire up the server daemons! </p></div></div></blockquote>
147<div>
148<center>
149<hr noshade size=1><TABLE WIDTH="515" BORDER="0" CELLSPACING="0" CELLPADDING="0">
150<TR>
151<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172">
152<A CLASS="sect1" HREF="ch02_03.html" TITLE="2.3 Compiling and Installing Samba">
153<IMG SRC="gifs/txtpreva.gif" ALT="Previous: 2.3 Compiling and Installing Samba" BORDER="0"></a></td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171">
154<A CLASS="book" HREF="index.html" TITLE="">
155<IMG SRC="gifs/txthome.gif" ALT="" BORDER="0"></a></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172">
156<A CLASS="sect1" HREF="ch02_05.html" TITLE="2.5 Starting the Samba Daemons">
157<IMG SRC="gifs/txtnexta.gif" ALT="Next: 2.5 Starting the Samba Daemons" BORDER="0"></a></td></tr><TR>
158<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172">
1592.3 Compiling and Installing Samba</td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171">
160<A CLASS="index" HREF="inx.html" TITLE="Book Index">
161<IMG SRC="gifs/index.gif" ALT="Book Index" BORDER="0"></a></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172">
1622.5 Starting the Samba Daemons</td></tr></table><hr noshade size=1></center>
163</div>
164
165<!-- End of sample chapter -->
166<CENTER>
167<FONT SIZE="1" FACE="Verdana, Arial, Helvetica">
168<A HREF="http://www.oreilly.com/">
169<B>O'Reilly Home</B></A> <B> | </B>
170<A HREF="http://www.oreilly.com/sales/bookstores">
171<B>O'Reilly Bookstores</B></A> <B> | </B>
172<A HREF="http://www.oreilly.com/order_new/">
173<B>How to Order</B></A> <B> | </B>
174<A HREF="http://www.oreilly.com/oreilly/contact.html">
175<B>O'Reilly Contacts<BR></B></A>
176<A HREF="http://www.oreilly.com/international/">
177<B>International</B></A> <B> | </B>
178<A HREF="http://www.oreilly.com/oreilly/about.html">
179<B>About O'Reilly</B></A> <B> | </B>
180<A HREF="http://www.oreilly.com/affiliates.html">
181<B>Affiliated Companies</B></A><p>
182<EM>&copy; 1999, O'Reilly &amp; Associates, Inc.</EM>
183</FONT>
184</CENTER>
185</BODY>
186</html>
187