Network Administration: Samba smb.conf File

If you like the raw power that comes from editing configuration files, fire up your favorite text editor and play with the Samba configuration file. It’s called smb.conf and is usually located in the /etc/samba directory, although some distributions may place this file in another location.

The following illustration shows you the smb.conf file being edited in the standard Text Editor program, which you can access by choosing Applications→Accessories→Text Editor.

image0.jpg

Any line in the smb.conf file that begins with a hash mark (#) or semicolon (;) is a comment. The default smb.conf file is loaded with comments that describe what each configuration line does. Plus, you can find many sample configuration entries that are commented out. The sample configuration lines are marked with a semicolon to distinguish them from explanatory text lines, which begin with a hash mark.

The overall structure of the smb.conf file is something like this:

[global]
    workgroup = workgroup
    server string = samba server
    security = USER
    encrypt passwords = yes
    smb passwd file = /etc/samba/smbpasswd
    guest ok = yes
    other global settings...
[sharename]
    comment = comment
    path = path
    writeable = yes

The first section of the file, marked by the [global] line, contains options that apply to the entire server. These are the options that are set by the Preferences→Server Settings command in the GNOME Samba Server Configuration program. The following table lists a few of the more common settings that you can use in the global section.

Common Global Settings for the smb.conf File
Setting Description
workgroup The name of the workgroup or domain.
server string The comment that describes the server.
hosts allow Lets you limit access to the Samba server to the IP addresses
listed. If a partial IP address is listed (for example, 192.168.1),
it is treated as a subnet.
guest ok Specify Yes to allow guest access.
guest account Specifies the Linux account to be used.
security Specifies the security mode: Domain, Server, Share, or
User.

Located after the global section is a section for each share that begins with the [sharename] line. The settings in these groups specify the details of a share, such as the comment and path. The following table lists the settings that you can specify for a share.

Share Settings for the smb.conf File
Setting Description
[sharename] The name used by the share.
path=path The path to the directory to be shared.
comment=comment A description of the shared resource.
guest ok Specify Yes to allow guest access.
writeonly Specify Yes for read/write, No for read-only.
browseable Specify Yes to make the share visible in My Network
Places.
valid users A list of users who can access the share.
hosts allow Lets you limit access to the Samba server to the IP addresses
listed. If a partial IP address is listed (for example, 192.168.1),
it’s treated as a subnet.

After you modify the smb.conf file and save your changes, you need to restart the SMB service in order for the changes to take effect.