Creating Network Shares Using Samba on Debian
There are times when we need to share files that must be viewable by Windows clients. Since Fuse-based systems only work on Linux, we'll be introducing a popular piece of software, called Samba. Samba implements protocols used by Windows such as workgroups, and allows for files to be viewed and modified through Windows. You can run Samba on Linux to share files with Windows clients.
This guide will explain how to setup a network share using Samba on Debian.
###Step 1: Installing Samba Let's begin. In order to use Samba, we need to install it. Run the following command as the root user.
apt-get install samba
###Step 2: Configuring Samba This is the difficult part - I'll be explaining each line in the configuration that gets added. For this article, we'll be using nano as the preferred text editor, but you can replace it with vim, or any similar text editor. Let's get to the configuration. Open it by running these commands as root.
When you scroll down in the configuration, the first option you'll encounter is
workgroup = WORKGROUP. On your Windows clients, you should have already set up a workgroup. We'll be using
workcomputers as the workgroup for this article. Edit the last part of that line and change
WORKGROUP to your workgroup, or for this article,
workcomputers. As we're using nano, we'll go to the bottom by holding the keys CTRL+W, then CTRL+V. This is where the magic happens - add these lines to the end of your configuration:
comment = description of the shared folder
read only = no
path = /networkShare
guest ok = yes
Here's an explanation of each line:
[networkShare] - You may edit the section between the brackets, but you must maintain the brackets.
comment = description - Edit the part after "comment =" to how you want to describe the share.
read only = no - If you want clients to not have the ability to manipulate files, change this to "yes".
path = /networkShare - Edit this to the folder you want to share.
guest ok = yes - For this article, we'll be keeping this easy, so don't change "yes".
After you've finished editing, hit CTRL+X, type Y and hit Enter. Then, we need to restart Samba:
service samba restart
The Samba setup is complete. At this point, you will start seeing the server in the Network section of My Computer on your Windows Client.
By setting up these shares, you'll be able to control if files can be modified, or only the ability to copy files. They're very easy to set up, and can be easily removed as well. You may add more shares with additional configuration blocks as described in step 2.