Creating a Simple File Share
After Samba is working properly, your first task is to create the directory on your Linux server that the server will use Samba to share. Whether you're in Linux or Windows, the process is the same: Create the directory, and ensure that the appropriate user or group owns it.
As the root user, enter the following mkdir command to create the directorywhich I named fileson the Linux file system:
# mkdir /home/samba/files
Notice the directory's placement under the home directory for Samba. Linux gives most services a user account and home directory. Locating directories for disk shares in the Samba home directory is a common Linux practice, although you can put your share on another disk or even a mounted network storage device. The directory's location is irrelevant if the storage medium is reliable.
You use the chown command to configure nobody (an account Linux creates automatically upon installation) to own this Linux directory. Linux administrators typically designate "nobody" as the user account for anonymous-style access.
# chown nobody /home/samba/files
Next, you configure your disk share in the user-defined section of Samba's configuration file. You first need to create a user-defined section by specifying the share name within square brackets below the global section. The name can be anything but the reserved section namesglobal, printers, and homesbut for simplicity's sake, name the section Files by typing
[Files]
Start with the comment parameter, which lets you apply a comment to the disk share. Apply a comment that will help users decipher the purpose of the share. For example,
comment = Network Files
Next, with the path parameter, specify which directory Samba will be sharing. For example, to locate the directory under the Samba home directory, you would set the parameter as follows:
path = /home/samba/files
You also need to specify whether the share is read-only or writeable. By default, Samba configures all disk shares as read-only. To let users write to shares, you need to use the writeable parameter to override the default:
writeable = yes
You can let Samba apply the read-only defaultfor disk shares that store drivers or other files that shouldn't be user-modifiableeither by not including this parameter or by entering the value no in the writeable parameter.
Finally, use the guest ok parameter to enable anonymous access to this share. Unless you allow anonymous access, any user who connects to the share needs to have an SMB account in Samba's local password database.
When you allow anonymous access, you also need to specify the Linux user account from which users can access the files on the disk share. (You can also specify this user account in the global section. This configuration would then serve as the default that you can override on a per-share basis.) This step is necessary because all access needs to satisfy the authorization requirements of both Samba and Linux. Use guest account to specify the user account nobody (the account with original ownership of the directory):
guest ok = yes
guest account = nobody
Sean Irish July 19, 2001