⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 296-299.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Special Edition Using Linux, Fourth Edition:Using Samba</TITLE>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!--ISBN=0789717468//-->

<!--TITLE=Special Edition Using Linux, Fourth Edition//-->

<!--AUTHOR=Jack Tackett//-->

<!--AUTHOR=Jr.//-->

<!--AUTHOR=Steve Burnett//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Que//-->

<!--CHAPTER=15//-->

<!--PAGES=296-299//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="293-296.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="299-302.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<P>The smb.conf file layout consists of a series of named sections. Each section starts with its name in brackets, as in [global]. Within each section, the parameters are specified by <I>key</I> = value pairs, such as comment = RedHat Samba Server.</P>

<P>smb.conf contains three special sections and one or more custom sections. The special sections are [global], [homes], and [printers].</P>

<H4 ALIGN="LEFT"><A NAME="Heading4"></A><FONT COLOR="#000077">The [global] Section</FONT></H4>

<P>The [global] section controls parameters for the entire smb server. The section also provides default values for the other sections.

</P>

<!-- CODE //-->

<PRE>

[global]



; workgroup = NT-Domain-Name or Workgroup-Name, eg: REDHAT4

   workgroup = WORKGROUP



; comment is the equivalent of the NT Description field

   comment = RedHat Samba Server



; volume = used to emulate a CDRom label (can be set on a per share basis)

   volume = RedHat4

</PRE>

<!-- END CODE //-->

<P>The first line from the global section in Listing 15.1 defines the workgroup that this machine will belong to on your network. Next the file specifies a comment for the system and identifies a volume label.

</P>

<!-- CODE SNIP //-->

<PRE>

; printing = BSD or SYSV or AIX, etc.

   printing = bsd

   printcap name = /etc/printcap

   load printers = yes

</PRE>

<!-- END CODE SNIP //-->

<P>The next entry tells the Samba server what type of printing system is available on your server, and the line after that indicates where the printer configuration file is located.

</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR>&#149; <B>See</B> &#147;Understanding the /etc/printcap File,&#148; <B>p. 411</B><HR></FONT>

</BLOCKQUOTE>

<P>The next line instructs Samba to make available on the network all the printers defined in the printcap file.

</P>

<!-- CODE SNIP //-->

<PRE>

; Uncomment this if you want a guest account

;  guest account = pcguest

   log file = /var/log/samba-log.%m

; Put a capping on the size of the log files (in Kb)

   max log size = 50

</PRE>

<!-- END CODE SNIP //-->

<P>The next entry indicates a username for a guest account on your sever. This account is used to authenticate users for Samba services available to guest connections.

</P>

<P>The log file entry specifies the location of the log file for each client who accesses Samba services. The <TT>%m</TT>  parameter tells the Samba server to create a separate log file for each client. The <TT>max log size</TT>  entry sets a maximum file size for the logs created.</P>

<H4 ALIGN="LEFT"><A NAME="Heading5"></A><FONT COLOR="#000077">The [homes] Section</FONT></H4>

<P>The [homes] section allows network clients to connect to a user&#146;s home directory on your server without having an explicit entry in the smb.conf file. When a service request is made, the Samba server searches the smb.conf file for the specific section corresponding to the service request. If it does not find the service, Samba checks to see if there is a [homes] section. If the [homes] section exists, Samba searches the password file to find the home directory for the user making the request. When it&#146;s found, this directory is shared with the network.

</P>

<!-- CODE SNIP //-->

<PRE>

[homes]

   comment = Home Directories

   browseable = no

   read only = no

   preserve case = yes

   short preserve case = yes

   create mode = 0750

</PRE>

<!-- END CODE SNIP //-->

<P>The <TT>comment</TT>  entry is displayed to the clients to let them know which shares are available. The <TT>browseable</TT>  entry instructs Samba how to display this share in a network browse list. The <TT>read-only</TT>  parameter controls whether a user can create and change files in his home directory when it is shared across the network. The <TT>preserve case</TT>  and <TT>short preserve case</TT>  parameters instruct the server to preserve the case of any information written to the server. This is important because Windows filenames are not typically case-sensitive, but Linux filenames are case-sensitive. The final entry sets the file permissions for any files created on the shared directory.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR>&#149; <B>See</B> &#147;File Permissions,&#148; <B>p. 310</B><HR></FONT>

</BLOCKQUOTE>

<H4 ALIGN="LEFT"><A NAME="Heading6"></A><FONT COLOR="#000077">The [printers] Section</FONT></H4>

<P>The [printers] section defines how printing services are controlled if no specific entries are found in the smb.conf file. Thus like the [homes] section, if no specific entry is found for a printing service, Samba uses the [printers] section (if it&#146;s present) to allow a user to connect to any printer defined in /etc/printcap.

</P>

<!-- CODE //-->

<PRE>

[printers]

   comment = All Printers

   path = /var/spool/samba

   browseable = no

   printable = yes

; Set public = yes to allow user &#145;guest account&#146; to print

   public = no

   writable = no

   create mode = 0700

</PRE>

<!-- END CODE //-->

<P>The <TT>comment</TT>, <TT>browseable</TT>, and <TT>create mode</TT>  entries mean the same as discussed above in the [homes] sections. The <TT>path</TT>  entry indicates the location of the spool file to be used when servicing a print request via SMB.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR>&#149; <B>See</B> &#147;Selecting a Printer to Work with Linux,&#148; <B>p. 406</B><HR></FONT>

</BLOCKQUOTE>

<P>The <TT>printable</TT>  value, if set to yes, indicates that this printer resource can be used to print. The <TT>public</TT>  entry controls whether the guest account can print.</P>

<H4 ALIGN="LEFT"><A NAME="Heading7"></A><FONT COLOR="#000077">Sharing Directories</FONT></H4>

<P>After configuring your defaults for the Samba server, you can create specific shared directories limited to just certain groups of people or to everyone. For example, suppose you want to make a directory available to only one user. To do so you would create a new section and fill in the needed information. Typically you&#146;ll need to specify the user, the directory path, and configuration information to the SMB server as shown here:

</P>

<!-- CODE SNIP //-->

<PRE>

[jacksdir]

comment = Jack&#146;s remote source code directory

path = /usr/local/src

valid users = tackett

browsable = yes

public = no

writable = yes

create mode = 0700

</PRE>

<!-- END CODE SNIP //-->

<P>This sample section creates a shared directory called jacksdir. The path to the directory on the local server is /usr/local/src. Because the <TT>browsable</TT>  entry is set to yes, jacksdir will show up in the network browse list. However, because the <TT>public</TT>  entry is set to no, only the user named tackett can access this directory using Samba. You can grant access to other users by listing them in the <TT>valid users</TT>  entry.</P>

<H4 ALIGN="LEFT"><A NAME="Heading8"></A><FONT COLOR="#000077">Testing the smb.conf File</FONT></H4>

<P>After creating the configuration file you should test it for correctness with the <TT>testparm</TT>  program. <TT>testparm</TT>  is a very simple test program to check the /etc/smb.conf configuration file for internal correctness. If this program reports no problems, you can use the configuration file with confidence that <TT>smbd</TT>  will successfully load the configuration file.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>CAUTION:&nbsp;&nbsp;</B><BR>Using testparm is NOT a guarantee that the services specified in the configuration file will be available or will operate as expected.<HR></FONT>

</BLOCKQUOTE>

<P><TT>testparm</TT> has the following command line:</P>

<!-- CODE SNIP //-->

<PRE>

testparm [<I>configfile</I> [<I>hostname hostip</I>]]

</PRE>

<!-- END CODE SNIP //-->

<P>where <I>configfile</I>  indicates the location of the smb.conf file if it is not in the default location (/etc/smb.conf). The <I>hostname hostIP</I>  optional parameter instructs <TT>testparm</TT>  to see if the host has access to the services provided in the smb.conf file.</P><P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="293-296.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="299-302.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -