Easily set Samba for various purposes

Source: Internet
Author: User
Article Title: easily set Samba for various purposes. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

In this article, we will learn the following concepts:

View Samba server configuration file structure

Use Samba variables and configuration parameters

Identify the key TCP/User datasync Protocol (UDP) port used by Server Message Block (SMB)/Common Internet File System (CIFS) to configure Samba logs to diagnose and debug problems using Samba

Samba configuration file

Like most UNIX daemon, Samba is configured through a human-readable text file instead of a graphical tool used to edit binary files. The most important configuration file is smb. conf, which contains all the parameters required for Samba to run in your environment.

Note: Although smb. conf was designed to be edited through a text editor, the Samba team developed a web-based Tool named Samba Web Administration Tool. Other tools such as webmin are also available. It is important to remember that you can still edit smb. conf before or after running these tools because you are operating on a text file.

The Samba configuration file has a relatively simple format and uses three different structures:

Sections. Sections divides the configuration file into independent parts. For example, a file is shared in its own region.

Parameters. Parameters is a key-value pair. A key is a well-known attribute, such as "read only ".

Comments. Comments allows you to annotate the configuration file without affecting the configuration. For example, it indicates the service desk ticket that records the shared information.

Sections

Building your own feed you can build an RSS, Atom, or HTML feed to receive notifications when we add new articles or update content. Visit the developerWorks RSS feed. Select Linux as the Zone, Articles as the type, and enter Linux Professional Institute as the keyword. Then select the type of the desired feed. Sections divides the configuration file into different parts. You can include the section name in square brackets ([]) to start a section. This section continues until the next section is defined or reaches the end of the file.

There are three section names with special meanings:

Global. All content in this section applies to the entire server. If necessary, you can overwrite the configuration items in the global section at the sharing level.

Homes. The homes part serves as a template shared by all users, and Samba is responsible for ing user names to the configurations in this section. Every time you want users to access their home directories, there is almost no need to configure independent sharing.

Printers. This part is similar to homes, but it is used for printers.

If the section name is not one of the above, it will be considered as file or printer sharing.

When a connection request for a specific share name enters Samba, the daemon looks for a section with the name and defines the shared attributes. If this section is not found, Samba browses the user list on the system to see if the connection is a user. If not, Samba queries the printer list to check whether the printer with this name exists. If the connection matches the user, the homes configuration is used. If the printer matches, use the printers section. In all cases, the region-level Configuration overwrites the global configuration section.

If none of the above conditions match, there will be the last check. If the default service is configured, the service is used. If no, an error is returned to the client. By default, the default service is not configured, so incorrect sharing names may cause errors.

Parameters

Parameters uses the form of key = value, which assigns value to the key. Keys are recorded on the smb. conf manual page. To a large extent, Samba configuration is to understand the keys required to implement the desired behavior and determine the appropriate keys to be used.

Parameters generally uses a string as a value. Samba supports macros, allowing you to change parameter values based on shared names or user input. For example, the homes part is set to the user's UNIX main directory by default, but you can use the macro to use this parameter at any location and replace the user name in the file path during connection. The macro starts with "%" and will be discussed as needed.

If the value of a parameter must be extended to two or more rows, all rows except the last row must end with a backslash (\), just like a UNIX shell.

Comments

Comments starts with a semicolon (;) or hash character (hash or. Comments can be used to explain the source of a project, track changes, or display section boundaries.

Configuration example

Listing 1 shows the smb. conf file example, which describes the different components of the file.

List 1. configuration file example

# This is a comment

; So is this

# Remember that all shares need to be entered in the Wiki! -Opsteam

[Global]

Workgroup = BIGCO

# % V gets expanded to the version of Samba

Server string = Samba Server Version % v

# By default any file starting with. will have the hidden attribute set

Hide dot files = yes

# Home directories come from the UNIX password file

# Anyone matching a user will use this section

[Homes]

Comment = Home directories

# Dot files will be hidden because it's a global

[Printers]

Comment = System printers

Printable = yes

# A share that everyone can see

[Projecta]

Path =/var/spool/projects/projecta

# Override the global version of hiding dot files

Hide dot files = no special note for this configuration example is:

Two different types of annotations are used. One starts with a hash and the other starts with a semicolon.

[1] [2] [3] [4] [5] [6] Next page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.